Many basic questions i cant find solution

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)
- 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)

Thankyou in advance

···

--
View this message in context: http://old.nabble.com/Many-basic-questions-i-cant-find-solution-tp31088840p31088840.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

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

···

On Mon, Mar 7, 2011 at 10:01 AM, Muffles <dantaresrah@…287…> wrote:

Thankyou for the reply, ill test that in a minute, and let you know the
result.

Benjamin Root-2 wrote:

Can you include a screenshot of what you see?

Here it is:
http://old.nabble.com/file/p31089197/hov.png

Thank you

···

On Mon, Mar 7, 2011 at 10:01 AM, Muffles <dantaresrah@...287...> wrote:

--
View this message in context: http://old.nabble.com/Many-basic-questions-i-cant-find-solution-tp31088840p31089197.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Benjamin Root-2 wrote:

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()

Well this just plots 2 different imagens now, one with only the axis, and
the other with the data and a default axis

···

--
View this message in context: http://old.nabble.com/Many-basic-questions-i-cant-find-solution-tp31088840p31104901.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Could you please include your code? My code was merely a
demonstration and not meant to be copy and pasted in it's entirety.

Ben Root

···

On Wednesday, March 9, 2011, Muffles <dantaresrah@...287...> wrote:

Benjamin Root-2 wrote:

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()

Well this just plots 2 different imagens now, one with only the axis, and
the other with the data and a default axis

Benjamin Root-2 wrote:

Could you please include your code? My code was merely a
demonstration and not meant to be copy and pasted in it's entirety.

Ben Root

Thx, but I fixed that already, it was my error.
Still dont cant fix the width of the window though...

···

--
View this message in context: http://old.nabble.com/Many-basic-questions-i-cant-find-solution-tp31088840p31107217.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

And, without the code, I can’t help you. Please include a small script that I can run that demonstrates the problem. I can’t reproduce your bug based on your description.

Ben Root

···

On Wed, Mar 9, 2011 at 9:11 AM, Muffles <dantaresrah@…287…> wrote:

Benjamin Root-2 wrote:

Could you please include your code? My code was merely a

demonstration and not meant to be copy and pasted in it’s entirety.

Ben Root

Thx, but I fixed that already, it was my error.

Still dont cant fix the width of the window though…

Benjamin Root-2 wrote:

And, without the code, I can't help you. Please include a small script
that
I can run that demonstrates the problem. I can't reproduce your bug based
on your description.

Ben Root

Here it is, i think this works

fig=figure(figsize=(5,9))

pcolor(rand(1000,60))

ax = fig.gca()
ax.set_yticks(np.arange(0, 1000, 100)) #define a legenda dos eixos
ax.set_yticklabels([0,1,2,3,4,5,6,7,8,9,10])
plt.axis((0,60,0,1000)) #corta os eixos

cax = axes([0.93, 0.1, 0.15, 0.8]) # setup colorbar axes
colorbar(cax=cax) # draw colorbar

plt.show()

···

--
View this message in context: http://old.nabble.com/Many-basic-questions-i-cant-find-solution-tp31088840p31107693.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Try this. It is a lot cleaner:

import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure(figsize=(5, 9))
ax = fig.gca()

pc = ax.pcolor(np.random.rand(1000, 60))

ax.set_yticks(np.arange(0, 1000, 100))
ax.set_yticklabels(range(11))
ax.set_xlim(0, 60)
ax.set_ylim(0, 1000)

fig.colorbar(pc)

plt.show()

I hope that helps!
Ben Root

···

On Wed, Mar 9, 2011 at 10:05 AM, Muffles <dantaresrah@…287…> wrote:

Benjamin Root-2 wrote:

And, without the code, I can’t help you. Please include a small script

that

I can run that demonstrates the problem. I can’t reproduce your bug based

on your description.

Ben Root

Here it is, i think this works

fig=figure(figsize=(5,9))

pcolor(rand(1000,60))

ax = fig.gca()

ax.set_yticks(np.arange(0, 1000, 100)) #define a legenda dos eixos

ax.set_yticklabels([0,1,2,3,4,5,6,7,8,9,10])

plt.axis((0,60,0,1000)) #corta os eixos

cax = axes([0.93, 0.1, 0.15, 0.8]) # setup colorbar axes

colorbar(cax=cax) # draw colorbar

plt.show()