Skip to content

How to use log scale on polar axis in matplotlib #19157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Haitham-Hajjo opened this issue Dec 21, 2020 · 1 comment
Closed

How to use log scale on polar axis in matplotlib #19157

Haitham-Hajjo opened this issue Dec 21, 2020 · 1 comment

Comments

@Haitham-Hajjo
Copy link

I am trying to create a polar plot with a log scale on the radial axis but I keep getting an error or I get a missed up plot.
This is the code that I use:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

metabolites = data[["metabolite"]]
intercepts = data[["intercept"]]
amplitudes= data[["amplitude"]]
acrophases = data[["acrophase"]]
ind = data[["Unnamed: 0"]]

N = metabolites.count()
N = N.values
N = N[0]

metabolites = metabolites.values
acrophases = acrophases.values
amplitudes = amplitudes.values
ind = ind.values
colors = plt.cm.gist_rainbow(ind[:,0]/len(acrophases))
width = np.zeros((N,1)) + 0.3

for i in range(len(acrophases)):
if acrophases[i] <0:
acrophases[i] = acrophases[i]+ np.pi

acrophases = acrophases[:,0]
amplitudes = amplitudes[:,0]
width1 = width[:,0]
metabolites = metabolites[:,0]
fig = plt.figure()
ax = plt.subplot(111, projection='polar')

for j in range(len(acrophases)):
ax.bar(acrophases[j], amplitudes[j], width=0.3, bottom=0.0, align='center', color=colors[j], label=metabolites[j])
handles, labels = ax.get_legend_handles_labels()
ax.set_xticklabels(['0', '3', '6', '9', '12', '15', '18', '21'])

ax.set_rlim((1.0, 10000.0))
ax.set_rscale('log')
fig.savefig('plot.tiff', dpi=600)
plt.show()

@jklymak
Copy link
Member

jklymak commented Dec 21, 2020

This is not a self-contained example, and you don't include a plot, but I suspect it is a duplicate of #7751 If not, please provide more detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants