data grid problem

Hello,

I'm new to matplotlib and I hope you can help me out with my question.
When drawing for example a Rectangle() I have to specify it like the
following:
rect = Rectangle((1, 3), 2, 20, facecolor="#aaaaaa")

Where 2 is the length and 20 is the height. (1,3) is for xy.

Imagine a coordination system where x-axis should represent the value 0
to 100. I would like to draw the rectangle from 50 to 60 on x-axis. So
I would specify:

rect = Rectangle((50, 3), 10, 20, facecolor="#aaaaaa")

But this does not work as desired because at the xtick 50 the x-axis
does not "hold" the value 50 but 5 because I made xticks 1-100 with step
10. So my x-axis "holds" the values 1-10. But I need 1-100.

If anyone knows what Im missing I d be glad to hear about it :-).

thank you

I am not quite sure I understand what you mean. Can you attach an image of the plot you made so far?

Ben Root

···

On Wed, Oct 10, 2012 at 9:40 AM, rand0m <rand0m@…4228…> wrote:

Hello,

I’m new to matplotlib and I hope you can help me out with my question.

When drawing for example a Rectangle() I have to specify it like the

following:

rect = Rectangle((1, 3), 2, 20, facecolor="#aaaaaa")

Where 2 is the length and 20 is the height. (1,3) is for xy.

Imagine a coordination system where x-axis should represent the value 0

to 100. I would like to draw the rectangle from 50 to 60 on x-axis. So

I would specify:

rect = Rectangle((50, 3), 10, 20, facecolor="#aaaaaa")

But this does not work as desired because at the xtick 50 the x-axis

does not “hold” the value 50 but 5 because I made xticks 1-100 with step

  1. So my x-axis “holds” the values 1-10. But I need 1-100.

If anyone knows what Im missing I d be glad to hear about it :-).

thank you

I'm not sure if adding a patch autoscales the view, try

rect = Rectangle((50, 3), 10, 20, facecolor="#aaaaaa")
ax.add_patch(rect)
ax.set_xlim(0, 100)
ax.set_ylim(0, 25)

···

On Wed, Oct 10, 2012 at 3:55 PM, Benjamin Root <ben.root@...1304...> wrote:

On Wed, Oct 10, 2012 at 9:40 AM, rand0m <rand0m@...4228...> wrote:

Hello,

I'm new to matplotlib and I hope you can help me out with my question.
When drawing for example a Rectangle() I have to specify it like the
following:
rect = Rectangle((1, 3), 2, 20, facecolor="#aaaaaa")

Where 2 is the length and 20 is the height. (1,3) is for xy.

Imagine a coordination system where x-axis should represent the value 0
to 100. I would like to draw the rectangle from 50 to 60 on x-axis. So
I would specify:

rect = Rectangle((50, 3), 10, 20, facecolor="#aaaaaa")

But this does not work as desired because at the xtick 50 the x-axis
does not "hold" the value 50 but 5 because I made xticks 1-100 with step
10. So my x-axis "holds" the values 1-10. But I need 1-100.

If anyone knows what Im missing I d be glad to hear about it :-).

thank you

I am not quite sure I understand what you mean. Can you attach an image of
the plot you made so far?

Ben Root

--
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

We managed to solve it, but apparently it was off-list. Essentially, I showed him how to use a MultipleLocator to control the axis ticks, rather than labeling them manually at a different scale.

Ben Root

···

On Thursday, October 11, 2012, Damon McDougall wrote:

On Wed, Oct 10, 2012 at 3:55 PM, Benjamin Root <ben.root@…1304…> wrote:

On Wed, Oct 10, 2012 at 9:40 AM, rand0m <rand0m@…878…4228…> wrote:

Hello,

I’m new to matplotlib and I hope you can help me out with my question.

When drawing for example a Rectangle() I have to specify it like the

following:

rect = Rectangle((1, 3), 2, 20, facecolor="#aaaaaa")

Where 2 is the length and 20 is the height. (1,3) is for xy.

Imagine a coordination system where x-axis should represent the value 0

to 100. I would like to draw the rectangle from 50 to 60 on x-axis. So

I would specify:

rect = Rectangle((50, 3), 10, 20, facecolor="#aaaaaa")

But this does not work as desired because at the xtick 50 the x-axis

does not “hold” the value 50 but 5 because I made xticks 1-100 with step

  1. So my x-axis “holds” the values 1-10. But I need 1-100.

If anyone knows what Im missing I d be glad to hear about it :-).

thank you

I am not quite sure I understand what you mean. Can you attach an image of

the plot you made so far?

Ben Root

I’m not sure if adding a patch autoscales the view, try

rect = Rectangle((50, 3), 10, 20, facecolor="#aaaaaa")

ax.add_patch(rect)

ax.set_xlim(0, 100)

ax.set_ylim(0, 25)

I thought that might have been the problem. Cheers for the follow-up Ben.

···

On Thu, Oct 11, 2012 at 1:52 PM, Benjamin Root <ben.root@...1304...> wrote:

On Thursday, October 11, 2012, Damon McDougall wrote:

On Wed, Oct 10, 2012 at 3:55 PM, Benjamin Root <ben.root@...1304...> wrote:
>
>
> On Wed, Oct 10, 2012 at 9:40 AM, rand0m <rand0m@...4228...> wrote:
>>
>> Hello,
>>
>> I'm new to matplotlib and I hope you can help me out with my question.
>> When drawing for example a Rectangle() I have to specify it like the
>> following:
>> rect = Rectangle((1, 3), 2, 20, facecolor="#aaaaaa")
>>
>> Where 2 is the length and 20 is the height. (1,3) is for xy.
>>
>> Imagine a coordination system where x-axis should represent the value 0
>> to 100. I would like to draw the rectangle from 50 to 60 on x-axis. So
>> I would specify:
>>
>> rect = Rectangle((50, 3), 10, 20, facecolor="#aaaaaa")
>>
>> But this does not work as desired because at the xtick 50 the x-axis
>> does not "hold" the value 50 but 5 because I made xticks 1-100 with
>> step
>> 10. So my x-axis "holds" the values 1-10. But I need 1-100.
>>
>> If anyone knows what Im missing I d be glad to hear about it :-).
>>
>> thank you
>>
>
> I am not quite sure I understand what you mean. Can you attach an image
> of
> the plot you made so far?
>
> Ben Root

I'm not sure if adding a patch autoscales the view, try

rect = Rectangle((50, 3), 10, 20, facecolor="#aaaaaa")
ax.add_patch(rect)
ax.set_xlim(0, 100)
ax.set_ylim(0, 25)

We managed to solve it, but apparently it was off-list. Essentially, I
showed him how to use a MultipleLocator to control the axis ticks, rather
than labeling them manually at a different scale.

Ben Root

--
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom