SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: <na...@te...> - 2004年11月29日 03:13:03
Greetings!
In a figure I'm generating, I need to plot a function rotated
90 degrees counter-clockwise, so that x-axis is vertical, and
y-axis is horizontal (increasing from right to left). I searched
the documentation and the examples and couldn't find how (what I
tried didn't work). Probably there is a simple way to do that, if
somebody can point that out, I would really appreciate. :)
Thanks in advance
---
José Alexandre Nalon
na...@te...
From: John H. <jdh...@ac...> - 2004年11月29日 14:57:25
>>>>> "Jos=E9" =3D=3D Jos=E9 Alexandre Nalon <na...@te...> writes:
 Jos=E9> Greetings! In a figure I'm generating, I need to plot a
 Jos=E9> function rotated 90 degrees counter-clockwise, so that
 Jos=E9> x-axis is vertical, and y-axis is horizontal (increasing
 Jos=E9> from right to left). I searched the documentation and the
 Jos=E9> examples and couldn't find how (what I tried didn't
 Jos=E9> work). Probably there is a simple way to do that, if
 Jos=E9> somebody can point that out, I would really appreciate. :)
Perhaps you can be a little more specific about what you want to do.
For a "plot", all you need to do is reverse the x and y arguments
and place your xlabel and ylabel accordingly. =20
 plot(y, x)
I could probably give you more help if you describe what you need in
addition this.
For a bar chart, use barh.
For printing, some backends (eg postscript) support landscape mode
 savefig(fname, orientation=3D'landscape'):
JDH
From: Alan G I. <ai...@am...> - 2004年11月29日 15:56:24
On 2004年11月29日, Jos=E9 Alexandre Nalon apparently wrote:
> In a figure I'm generating, I need to plot a function rotated
> 90 degrees counter-clockwise, so that x-axis is vertical, and
> y-axis is horizontal (increasing from right to left). I searched
> the documentation and the examples and couldn't find how (what I
> tried didn't work). Probably there is a simple way to do that, if
> somebody can point that out, I would really appreciate. :)
Can you fill in your needs more precisely.
Why can you not just switch the order of
the sequences you provide to 'plot'
(perhaps in a loop is there are several)?
Cheers,
Alan Isaac
From: <na...@te...> - 2004年11月29日 16:30:04
Hello!
> Perhaps you can be a little more specific about what you want to do.
I think that a 'picture' can help - in this case, I think fixed
fonts will really help understanding. I remember using some
command in Matlab to do this, but can't remember exactly what
it was, and I can't search the help because I uninstalled it.
What I need is, basically, this:
 *| x
 * |
 * |
 * |
 * |
 * |
 * |
y --------------------------+
> plot(y, x)
That, and setting the x_lim inverted, worked as I wanted, thanks.
But one more thing: while I was searching for a specific command
to do that, I found something (but not much) about transforms, which
I couldn't exactly understand what they do and how they work, but
they might be handy in the near future. What are they exactly, and
how can they help?
---
José Alexandre Nalon
na...@te...
From: John H. <jdh...@ac...> - 2004年12月01日 05:21:45
>>>>> "Jos=E9" =3D=3D Jos=E9 Alexandre Nalon <na...@te...> writes:
 Jos=E9> That, and setting the x_lim inverted, worked as I wanted,
 Jos=E9> thanks.
Great
 Jos=E9> But one more thing: while I was searching for a specific
 Jos=E9> command to do that, I found something (but not much) about
 Jos=E9> transforms, which I couldn't exactly understand what they do
 Jos=E9> and how they work, but they might be handy in the near
 Jos=E9> future. What are they exactly, and how can they help?
The official documentation is at
http://matplotlib.sf.net/matplotlib.transforms.html , but this may be
of limited help because it is not a tutorial.
matplotlib is divided conceptually into three parts: the "matlab
interface" which are the plot functions that most people use and see,
the object oriented "artists" which are classes that store the figure
information and the "backends" which actually put the ink on the paper.
The "artists" are things like lines, text, rectangles, images and so
on, and all of them are concrete classes derived from
matplotlib.artist.Artist. Stupid name, I know, but I'm weak when it
comes to naming. There are, at a minimum, two coordinate systems to
consider when you plot, the "world" coordinates, ie your data
coordinates, and the display coordinates, which are physical locations
on the display device. The mapping between these two is given by a
transformation.
matplotlib transformations generally store the information about the
data coordinates and display coordinates, and possibly also a
nonlinear function (eg, polar, log). Every artist stores it's own
transform, and you can place different artists in the figure using
different coordinate systems (transforms).
The vast majority of all plot commands use the default data->display
transform and this is invisible in normal usage. But for convenience
and internal usage, matplotlib provides a couple of extra
transformations that you can make use of. For example, suppose you
wanted to place a rectangle in the middle of the axes that was 25%
from the left, bottom, top and right. You would place this rectangle
in the axes in what I refer to as axes coordinates, where 0 is the
left side of the axes, 1 is the width, 0.5 is the middle and so on.
This hypothetical rectangle has left, bottom=3D0.25, 0.25 and width,
height=3D0.5, 0.5
 from matplotlib.matlab import *
 from matplotlib.patches import Rectangle
 ax =3D subplot(111)
 plot([1,2,3])
 trans =3D ax.transAxes
 r =3D Rectangle( (0.25, 0.25), 0.5, 0.5, transform=3Dtrans)
 ax.add_patch(r)
 show()
 =20
Likewise, the figure instance provides a default transformation to
allow you to place objects in figure coordinates, where 0,0 is the
bottom left of the figure, 0.5, 0.5 is the middle and 1,1 is the upper
right. =20
Internally, I use this all the time. For example, I may want to place
the x-ticklabels a few points under the bottom of the y location of
the x-axis, and I have a transformation that allows me to do this with
minimal coding overhead in the presence o figure resizing, dpi
changes, etc.
These are examples of the transformations that are provided by
default, and they tend to cover most of the things people want to do.
But if you want to do something more, you can use affine
transformation (matplotlib.transforms.Affine) or otherwise and set
this for a given artist to place the object into the figure as you
like it.
The example examples/alignment_test.py in the matplotlib src
distribution makes heavy use of placing text in axes coordinates, so
you may want to take a look at this for an example.
JDH
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /