I am new to Python (I used to be an IDL user), so I hope that I ask for this in an understandable way. I am trying to create a polar graph with x number of boxes where the data in the bunker is averaged and the color associated with this value is set. This seems to work fine when using the plt.fill command, where I can define the cell and then the fill color. The problem arises when I try to make a colored strip for this. I keep getting errors pointing to the AttributeError attribute: The Figure object does not have the autoscale_None attribute
Any advice would be helpful.
import matplotlib.pyplot as plt import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt import matplotlib.cm as cm from matplotlib.pyplot import figure, show, rc, grid import pylab r = np.arange(50)/5. rstep = r[1] - r[0] theta = np.arange(50)/50.*2.*np.pi tstep = theta[1] - theta[0] colorv = np.arange(50)/50.
* here is a slightly better example of my real data, there are no holes everywhere, so in this example I just made a big quarter circle. When I tried to get stuck, the code seems to be trying to interpolate these areas.
r = np.arange(50)/50.*7. + 3. rstep = r[1] - r[0] theta = np.arange(50)/50.*1.5*np.pi - np.pi tstep = theta[1] - theta[0] colorv = np.sin(r/10.*np.pi) # force square figure and square axes looks better for polar, IMO width, height = mpl.rcParams['figure.figsize'] size = min(width, height) # make a square figure fig = figure(figsize=(size, size)) ax = fig.add_axes([0.1, 0.1, .8, .8])#, polar=True) my_cmap = cm.jet for j in range(len(r)): rbox = np.array([r[j], r[j], r[j]+ rstep, r[j] + rstep]) for i in range(len(theta)): thetabox = np.array([theta[i], theta[i] + tstep, theta[i] + tstep, theta[i]]) x = rbox*np.cos(thetabox) y = rbox*np.sin(thetabox) plt.fill(x,y, facecolor = my_cmap(colorv[j])) # Add colorbar, make sure to specify tick locations to match desired ticklabels #cbar = fig.colorbar(fig, ticks=[np.min(colorv), np.max(colorv)]) #cb = plt.colorbar() plt.show()
And then with the gear ...
from matplotlib.mlab import griddata p>
r = np.arange(50)/5. rstep = r[1] - r[0] theta = np.arange(50)/50.*1.5*np.pi - np.pi tstep = theta[1] - theta[0] colorv = np.sin(r/10.*np.pi) # force square figure and square axes looks better for polar, IMO width, height = mpl.rcParams['figure.figsize'] size = min(width, height) # make a square figure fig = figure(figsize=(size, size)) ax = fig.add_axes([0.1, 0.1, .8, .8])#, polar=True) my_cmap = cm.jet x = r*np.cos(theta) y = r*np.sin(theta) X,Y = np.meshgrid(x,y) data = griddata(x,y,colorv,X,Y) cax = plt.contourf(X,Y, data) plt.colorbar() # Add colorbar, make sure to specify tick locations to match desired ticklabels #cbar = fig.colorbar(fig, ticks=[np.min(colorv), np.max(colorv)]) #cb = plt.colorbar() plt.show()