From: Benjamin R. <ben...@ou...> - 2011-03-07 16:37:40
|
On Mon, Mar 7, 2011 at 10:01 AM, Muffles <dan...@gm...> wrote: > > Hello, i am not a user of matplotlib, i just have to do something in it. > I managed to get the plot i wanted, but i have been going around for hours > trying to do some fine tuning and cant get around it. The matplotlib seems > way too extense for me to find the solutions without studying it avidly, > and > i just dont have the time... > But trust me, i've looked everywhere and tried everything... > > What i need to do is: > - Change the axes labeling (if its like 1 2 3 4 5 6 change it to A B C D > for example) > You want set_xticklabels() (or set_yticklabels()): http://matplotlib.sourceforge.net/api/axes_api.html?highlight=set_xticklabels#matplotlib.axes.Axes.set_xticklabels Note that will not change the number of ticks already established for the axis. For that, you can use set_xticks(), which accepts a list of values where to set the tick marks (you should probably use set_xticklabels() after set_xticks()). Note that you will need to have access to the axes object. For example: import matplotlib.pyplot as plt fig = plt.figure() ax = fig.gca() # <--- the axes object I was talking about... ax.scatter([], []) ax.set_xticks([0.2, 0.4, 0.6, 0.8]) ax.set_xticklabels(['A', 'B', 'C', 'D']) plt.show() > - Resize the window, not the plot (I have the figsize=(6,10) and thats > fine > for the plot, but the colorbar just gets cut in half, cant fit in the > window) > > Can you include a screenshot of what you see? Ben Root |