[Matplotlib-users] contour plots with logarithmic axes
Is there any way to simply make a contour plot with logarithmic axes using matplotlib? I found a workaround by plotting log10(x), log10(y), but it'd be nicer if it was more direct. As someone new to matplotlib (experienced in IDL) I'm finding much to like, but some things are more difficult for no clear reason. It would seem to me that whether the axes are logarithmic or not would be a nice thing to have as an attribute of the plot object. I'm not familiar yet with the matplotlib internals to know how difficult that would be to implement, but it sure would be convenient. Jon Slavin -- This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Adding points gradually to the plot
Instead of appending the points to xs and ys and doing plot(xs,ys) each time, why not just do plot(x,y)? If you want to save the data in the xs, ys arrays you can do that without replotting the entire array. Jon On Wed, 2010-01-13 at 10:14 -0800, Someday... wrote: > Hello all, > > I am looking for a way to add points gradually to the plot over time. > Currently, in every iteration, I plot the entire array, like: > > fig = plt.figure(); > ax = fig.gca() > xs = array([]) > ys = array([]) > while not done: > // do some calculation.. > // x=???, y=??? > xs = append(xs,x); > ys = append(ys,y); > ax.plot(xs,ys) > plt.draw() > > However, it seems like that the figure is re-drawn completely and so > significantly harms the performance. Rather, I want to add point each > iteration to the plot. > > fig = plt.figure(); > ax = fig.gca() > while not done: > // do some calculation.. > // x=???, y=??? > ax.AddPoint(x,y) > plt.draw() // or update()? > > I searched tutorials, but I couldn't find anything related yet. If anyone > knows how, please let me know. > > Thanks all, > -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] defining/saving contours without plotting
To matplotusers: I want to create a plot that has an image and overplots contours, but the contours are defined relative to different data from that plotted in the image. Is there a way to save contour line data rather than plot it. It just occurred to me a way of creating the plot -- but I'm still interested in a way to save contour data. Jon -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] how to use different font for serif
Hi all,
I've been trying to use a different serif font for a plot and have been
running into problems. I thought I could just do something like:
from matplotlib import rc
rc('font', family='serif', serif='Times New Roman')
but if I try that I end up getting:
findfont: Font family ['serif'] not found. Falling back to Bitstream
Vera Sans
It works fine without the serif='...' part and gives me the default
serif font. I know that Times New Roman exists on my system -- at least
the GNOME character map can find it. Perhaps I need to use a different
alias (but what would it be?). Any help would appreciated.
Jon
--
__
Jonathan D. Slavin Harvard-Smithsonian CfA
[email protected] 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
__
--
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how to use different font for serif
Tony,
Thanks for your answer. I'm running on CentOS Linux. Unfortunately
there is no such command as font_manager.X11InstalledFonts(), though
there is font_manager.x11FontDirectory(). When I do that I get a list
with a bunch of directories including '/usr/share/msttcorefonts', which
contains the times.ttf which has the Times New Roman font I wanted. And
by doing things like:
fprop = font_manager.FontProperties(fname=
'/usr/share/fonts/msttcorefonts/times.ttf')
set_xlabel('X title',fontproperties=fprop)
xticklabels = plt.getp(plt.gca(), 'xticklabels')
plt.setp(xticklabels, fontproperties=fprop)
I can get the fonts I want for xlabel, ylabel, etc., but I still can't
get that font set as the default font (using, for example 'times' for
the value for serif, or for family). For some reason setting the
rcParam doesn't work. In the context in which it's invoked to find the
font, the font manager can't find it. So far I haven't been able to
track down the problem.
Jon
On Fri, 2011-12-02 at 17:30 -0500, Tony Yu wrote:
> On Fri, Dec 2, 2011 at 4:13 PM, Jonathan Slavin
> wrote:
> Hi all,
>
> I've been trying to use a different serif font for a plot and
> have been
> running into problems. I thought I could just do something
> like:
>
> from matplotlib import rc
> rc('font', family='serif', serif='Times New Roman')
>
> but if I try that I end up getting:
> findfont: Font family ['serif'] not found. Falling back to
> Bitstream
> Vera Sans
>
> It works fine without the serif='...' part and gives me the
> default
> serif font. I know that Times New Roman exists on my system
> -- at least
> the GNOME character map can find it. Perhaps I need to use a
> different
> alias (but what would it be?). Any help would appreciated.
>
> Jon
>
>
> You should check what fonts are installed on your system:
>
> >>> from matplotlib import font_manager
> >>> font_manager.OSXInstalledFonts()
>
> (or if you're on a different system, try MSInstalledFonts or
> X11InstalledFonts---those aren't available on my system, but
> presumably that's just because I'm using OSX). If that works, then
> look for Times New Roman in what's printed out. If it is, the problem
> may be that it's not the right format: it appears as if the
> font_manager only supports .ttf and .afm fonts.
>
> If you don't see Times New Roman in any of those files, check the
> output of
>
> >>> mpl.font_manager.OSXFontDirectories
>
> (replacing OSX with MS or X11, if needed). If the listed directories
> doesn't match your installation of Times New Roman, that's your
> problem. (I'm not sure if there's a good way of adding directories.)
>
> Cheers,
> -Tony
>
--
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how to use different font for serif
From: Michael Droettboom > > To: [email protected] > > Subject: Re: [Matplotlib-users] how to use different font for serif > > Date: Mon, 5 Dec 2011 14:49:09 -0500 > > > > What rcParams are you setting? > > > > font.family: serif > > font.serif: Times New Roman > > > > and > > > > font.family: Times New Roman > > > > both work for me. > > > > You have to use the name of the font as specified in the file, not > > the filename to specify the font (which is probably why "times" is > > not working for you). > > > > Mike I tried both of those and just tried them again and neither work for me: In [2]: rcParams['font.family'] = 'serif' In [3]: rcParams['font.serif'] = ['Times New Roman'] In [4]: plot([0,1,2]) Out[4]: [] In [5]: /usr/local/lib/python2.6/site-packages/matplotlib/font_manager.py:1242: UserWarning: findfont: Font family ['serif'] not found. Falling back to Bitstream Vera Sans (prop.get_family(), self.defaultFamily[fontext])) In [7]: rcParams['font.family'] = 'Times New Roman' In [8]: plot([0,1,2]) Out[8]: [] In [9]: /usr/local/lib/python2.6/site-packages/matplotlib/font_manager.py:1242: UserWarning: findfont: Font family ['Times New Roman'] not found. Falling back to Bitstream Vera Sans (prop.get_family(), self.defaultFamily[fontext])) What is it that tells the font_manager where to look? Jon -- Cloud Services Checklist: Pricing and Packaging Optimization This white paper is intended to serve as a reference, checklist and point of discussion for anyone considering optimizing the pricing and packaging model of a cloud services business. Read Now! http://www.accelacomm.com/jaw/sfnl/114/51491232/ ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how to use different font for serif
Finally found a solution for this -- actually just tried solution from Piter_ in his post -- deleted fontList.cache and it works. That is, just doing rcParams['font.family'] = 'Times New Roman' gives me that font as the default. Jon > From: Michael Droettboom > > > To: [email protected] > > > Subject: Re: [Matplotlib-users] how to use different font > for serif > > > Date: Mon, 5 Dec 2011 14:49:09 -0500 > > > > > > What rcParams are you setting? > > > > > > font.family: serif > > > font.serif: Times New Roman > > > > > > and > > > > > > font.family: Times New Roman > > > > > > both work for me. > > > > > > You have to use the name of the font as specified in the > file, not > > > the filename to specify the font (which is probably why > "times" is > > > not working for you). > > > > > > Mike > > I tried both of those and just tried them again and neither > work for me: > > In [2]: rcParams['font.family'] = 'serif' > > In [3]: rcParams['font.serif'] = ['Times New Roman'] > > In [4]: plot([0,1,2]) > Out[4]: [] > > In [5]: > > /usr/local/lib/python2.6/site-packages/matplotlib/font_manager.py:1242: > UserWarning: findfont: Font family ['serif'] not found. > Falling back to > Bitstream Vera Sans > (prop.get_family(), self.defaultFamily[fontext])) > > > In [7]: rcParams['font.family'] = 'Times New Roman' > > In [8]: plot([0,1,2]) > Out[8]: [] > > In [9]: > > /usr/local/lib/python2.6/site-packages/matplotlib/font_manager.py:1242: > UserWarning: findfont: Font family ['Times New Roman'] not > found. > Falling back to Bitstream Vera Sans > (prop.get_family(), self.defaultFamily[fontext])) > > What is it that tells the font_manager where to look? > > Jon -- Cloud Services Checklist: Pricing and Packaging Optimization This white paper is intended to serve as a reference, checklist and point of discussion for anyone considering optimizing the pricing and packaging model of a cloud services business. Read Now! http://www.accelacomm.com/jaw/sfnl/114/51491232/ ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] patheffects for Line2D objects
Hi, It seems that patheffects are not supported for Line2D objects currently - only for Text and Patch objects. Is there any fundamental reason they couldn't be extended to support Line2D objects? I'm interested in this because I draw grid lines for some hammer projection plots and those lines are Line2D objects. For certain images, it'd be nicer to have the grid lines use patheffects so that any color of the image would still allow the grid line to show clearly. Jon -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Write once. Port to many. Get the SDK and tools to simplify cross-platform app development. Create new or port existing apps to sell to consumers worldwide. Explore the Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join http://p.sf.net/sfu/intel-appdev ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] cycling mechanism
Just one quick thought. I hope that you will implement a longer default color cycle than the current default. I have several times run into situations where I have to either modify the cycle or specify the colors manually because I had more than 7 lines. Also, it'd be nice to have the colors be as distinguishable as possible (at least early in the cycle). I agree that having linestyle cycling as well would be nice, though it's difficult to imagine as many distinguishable line styles as colors, though there could certainly be more than the current 4. I wonder about a simple mechanism to opt for line style cycling rather than color cycling so as to produce black & white plots (as mentioned in another post). Jon > Hello all, > > So, I am getting to the point where I need to implement a color > cycling mechanism throughout pyplot. So, before I get too deep in > implementing it, I have some thoughts that I need feedback on. > > Thoughts? Comments? -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex infrastructure or vast IT resources to deliver seamless, secure access to virtual desktops. With this all-in-one solution, easily deploy virtual desktops for less than the cost of PCs and save 60% on VDI infrastructure costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Why pixel marker size is 4 pixels?
Chris,
You might want to try a module written by Tom Robitaille (aka astrofrog)
called rasterized_scatter. Look for it on github.
Jon
On Mon, 2012-02-06 at 21:28 +0900, Jae-Joon Lee wrote:
> Thanks. Now I understand the situation.
>
> As far as I can see, marker="," is implemented as a rectangle path
> with width/height of 1 pixel, so this result in 2x2 pixel filled
> square.
> I tried to change the size of the rectangle, etc, to get a single
> pixel filled square, but did not get a satisfactory result.
> I think we need an Agg expert. I hope Mike or others take a look.
>
> Chris,
> if you do not get a response from others in this mailing list, I
> recommend you to open a new issue in our github page.
>
> Regards,
>
> -JJ
>
>
> On Mon, Feb 6, 2012 at 1:53 AM, Chris wrote:
> > Thanks JJ.
> >
> > The problem seems not to be a size issue -- markersize has no effect
> > when use marker="," (pixel). I have also tried to turn off aa, and it
> > doesn't help either. I also tried different backends. The PNG output
> > from Agg and Cairo is slightly different: Agg's point has 4 solid
> > pixel, while Cairo's has 4 pixel with random shade.
> >
> > Postscript output has the same problem. The "pixel" in an EPS file
> > generated by mpl is significantly bigger than that from another
> > drawing program I used.
> >
> > The problem occurs in all my plotting scripts, e.g., this basic one:
> >
> > [CODE]
> > import numpy as np
> >
> > x=np.arange(100)
> > y=np.random.randn(100)
> >
> > ioff()
> > fig=gcf()
> > fig.clf()
> >
> > ax=fig.add_axes(0.15,0.1,0.8, 0.85)
> > ax.plot(x,y,"k,")
> >
> > ion()
> > fig.canvas.draw()
> > [/CODE]
> >
> > Here is how I identify the problem:
> > 1. use the above script to plot on screen
> > 2. savefig("plot.png")
> > 3. open plot.png in GIMP and check the pixel size.
> >
> > I also attached the two PNG files generated with Agg and Cairo backends.
> >
> >
> > On Sun, Feb 5, 2012 at 6:45 AM, Jae-Joon Lee wrote:
> >> How are you plotting your points.
> >>
> >> If you use *plot*, there is a *markersize* parameter.
> >> If you use *scatter*, the third argument controls the marker size.
> >>
> >> But you may actually complaining about other issues, e.g.,
> >> antialiasing, etc. So, if above are not your answer, please post a
> >> complete example and describe your problem in more detail.
> >>
> >> Regards,
> >>
> >> -JJ
> >>
> >>
> >> On Sat, Feb 4, 2012 at 2:15 PM, Chris wrote:
> >>> I noticed this a few years back, but left it aside because most of the
> >>> time I can live with it. Recently I need to make a few plots
> >>> containing a few million points, and 4 pixels for a point is a
> >>> disaster. So my question is why the pixel marker size is set at 4
> >>> pixels? And is there anyway to change it to a single pixel?
> >>>
> >>> Thanks,
> >>> Chris
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] x and y labels that span multiple axes
Hi all, I'm plotting a set of subplots (2 x 3) and I'd like to label the x and y axes with one title each (i.e. spanning the axes) since the units of all the x axes and y axes are the same. I know that I can use fig.text to do it, though that would require some fiddling on my part to get the placement right. Is there an easier way? Jon -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] matplotlib website problems?
Hi, Recently on several occasions I have gotten the response "Too many requests, please try again later." when trying to go to a matplotlib webpage. Have others experienced this also? Is this a problem with sourceforge? I'm wondering what could be done about this. It's very annoying when, for example, you want to see the source code for some useful example and you have to try back several times to get to the page. Jon -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] waitforbuttonpress DeprecationWarning
Hi, I've been writing a routine that interactively finds fitting limits. Some of the time it seems that doing draw() flushes the output to the figure and some of the time it doesn't. The only way I can reliably get it to do that is to insert a waitforbuttonpress into the code. However, this raises a DeprecationWarning: DeprecationWarning: Using default event loop until function specific to this GUI is implemented That of course doesn't cause any real problems, but I'd like to know how it should be done properly since using waitforbuttonpress creates this warning. Or maybe it's just a warning that in the future, once the event loop function is written for my backend (gtkagg) this function won't necessarily exist? I'd just as soon not use it, but I don't know another way to force the updating of the figure. Jon -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Better than sec? Nothing is better than sec when it comes to monitoring Big Data applications. Try Boundary one-second resolution app monitoring today. Free. http://p.sf.net/sfu/Boundary-dev2dev ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] customised linestyle?
The example here: http://matplotlib.sourceforge.net/examples/pylab_examples/dash_control.html?highlight=set_dashes will probably help. Jon > See the API document of plot(): > > http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.plot > > You may try different combinations of linestyle and marker to achieve > your desired style. > > ~Pengkui > > > On Fri, May 4, 2012 at 10:39 AM, Chao YUE > wrote: > Dear all, > > Is it possible to have a customized linestyle for line plots? > such as I want '--.--.--.' or '-*-*-*' or others. > > I read the documentation part of set_drawstyle and a post > here: > > http://old.nabble.com/Changing-the-Dash-Spacing--td33381003.html#a33381003 > > but still not clear. Could anyone give a very small example? > > thanks et cheers, > > Chao -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] mimic alpha (channel) v0.1
Francesco, While I like your solution, there is an alternative that is simpler and works for me. That is 1) save matplotlib plot as a png, 2) convert to eps using either ImageMagick or GraphicsMagick. You do end up with relatively large files, but they look identical to the original plots. Regards, Jon > Dear matplotlibers, > > after spending some more time about my problem on how to > emulate > transparency to create nice eps figures with shaded areas, > I found this web page: > > http://stackoverflow.com/questions/2049230/convert-rgba-color-to-rgb?rq=1 > > So I decided to implement the algorithm and it seems that the > approach > works (see attached pdf). > Of course if there are many layers of transparent colors, it > would be > very hard to get the exact colors, but so far it's the best > approach > that I've found. > > The code can be downloaded from here: > https://github.com/montefra/mimic_alpha/downloads > > Cheers, > Francesco -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] mimic alpha (channel) v0.1
Ben, Yes, you're right, but I doubt any solution that involves mimicking an alpha channel will work for one case that I've been using. That is, making the legend box partially transparent. I use that to allow the box to fit in the plot without blocking the data and without the need to make the upper y limit too large. I don't notice any problems with blockiness in the text or lines in the raster image. I'll find out soon if the editors of the Astrophysical Journal are okay with the figures. Jon On Tue, 2012-07-17 at 15:34 -0500, Benjamin Root wrote: > > > On Tue, Jul 17, 2012 at 3:01 PM, Jonathan Slavin > wrote: > Francesco, > > While I like your solution, there is an alternative that is > simpler and > works for me. That is 1) save matplotlib plot as a png, 2) > convert to > eps using either ImageMagick or GraphicsMagick. You do end up > with > relatively large files, but they look identical to the > original plots. > > Regards, > Jon > > No, it is not the same thing. Text in a vector-based format such as > eps is scalable. ImageMagick and GraphicsMagick are inherently > raster-based, and before that, PNGs are raster-based. Therefore, the > text is not scaled and anti-aliased according to the display size. > > I will be looking over the proposed solution this evening. > > Cheers! > Ben Root > > -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] wrapping y axis tick labels?
You might want to look at the python textwrap module. That can take your labels and automatically wrap them at a certain column width. See (in addition to the official python docs) http://www.doughellmann.com/PyMOTW/textwrap/ Jon On Fri, 2012-07-20 at 23:55 -0400, C M wrote: > How possible would it be to wrap y axis tick labels after a certain > text length? I have a horizontal bar plot where some bars' labels are > too long and therefore cut off. I can scrunch the width of the whole > plot to accommodate them, but I'd much rather wrap long text and allow > a little more space to accommodate two lines. For examples: > > I'd like to go from this: > >a short axis label | == > > A very long axis label that gets cut off | = > > > To this: >a short axis label | == > > A very long axis label | = > that gets cut off > > > Is this possible or has it ever been done? > > Thanks, > Che > > -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] problems making grayscale lines
D'oh! Caught my mistake. I was thinking of the grayscale backwards. color = '1.0' is white not black! Got it working now. Jon -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] problems making grayscale lines
Hi all, I'm trying to make a plot with several lines, each with a different grayscale color. I thought I could do something like clrs = ['0.125', '0.25', '0.375', '0.5', '0.625', '0.75', '0.875', '1.0'] and then either set the color cycle using clrs or just use the color=clrs[i] argument in a loop that draws the lines. This kind of works, but it seems that there's some autoscaling going on. If I use values ranging from 0 to 1, the curve with 0 doesn't show up at all (which I would expect) and the curve with 1 is black. If I use values ranging from 0.5 to 1, the curve with 0.5 doesn't show up and the curve with 1 is gray instead of black. What gives? How can I get a set of curves with gray values ranging from medium gray to black? As a simple demo if I do: import matplotlib.pyplot as plt import numpy as np import matplotlib.cm as cmap x = np.linspace(0,1.,num=10) y1 = 0.5*x y2 = 0.4*x fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.plot(x,y1,color='0.5') ax.plot(x,y2,color='1.0') ax.legend(['y1','y2']) plt.show() I get a single visible line that is a sort of medium gray. Jon -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] open circles aren't showing up in the legend box
Joe, I think the problem is the edgecolor='face' in the scatter call for the open circles. For me when I omit that, it all works. I'd also note that calling legend after draw results in the legend showing the circles correctly colored. Regards, Jon On Wed, 2013-01-02 at 16:46 -0800, Joe Louderback wrote: > Using matplotlib.pyplot I create a scatter plot using two symbols, an > open circle, and a filled circle. The legend for this plot shows both > labels, but there is no symbol for the open circles (see > missing_legend_circles.png). Switching to matplotlib.pylab yields the > same result. However, from an "ipython --pylab" session the open > circles are displayed in the legend. This has me more baffled than > usual. Here's the code to reproduce the enclosed figure: > > import matplotlib.pyplot as plt > > > fig = plt.figure() > plot = fig.add_subplot(111) > > > plot.scatter([1, 2, 3], [4, 5, 6], c = [0.2, 0.4, 0.6], label = > 'one', > cmap = 'jet', marker = 'o', edgecolor = 'face') > > > plot.scatter([1, 2, 3], [7, 6, 5], c = [0.2, 0.4, 0.6], label = 'two', > cmap = 'jet', marker = 'o', edgecolor = 'face', > facecolor = 'none') > plot.legend() > plt.show() > > > > > This is with matplotlib 1.1 and 1.2 on Windows 7 with the TkAgg, WxAgg > and WX backends. > > > Thank you for any help. > > > -- Joe Louderback -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnmore_122712 ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] twiny and title
Hi, I'm having some trouble with using twiny and a title on the plot. The title is writing over the axis label -- and even the tick labels. I've tried tight_layout() but it doesn't seem to help. I could use fig.text instead of title and place the title text where I want it (with a bit of fiddling), but it'd be nice to have a more elegant solution. Jon -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnnow-d2d ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] twiny and title
Hi Paul,
This doesn't solve my problem since the whole point was to have two
separate x axes with different scales, etc. One thing that I found that
does help is to use the suptitle() method of figure. This at least puts
the title at the top of the figure and I can then fiddle with the top
offset for the subplot to get the title to not overlap the axis label.
Jon
On Tue, 2013-01-22 at 13:02 -0800, Paul Hobson wrote:
>
> On Tue, Jan 22, 2013 at 12:22 PM, Jonathan Slavin
> wrote:
> Hi,
>
> I'm having some trouble with using twiny and a title on the
> plot. The
> title is writing over the axis label -- and even the tick
> labels. I've
> tried tight_layout() but it doesn't seem to help. I could use
> fig.text
> instead of title and place the title text where I want it
> (with a bit of
> fiddling), but it'd be nice to have a more elegant solution.
>
>
> Try this is a workaround:
> fig, ax1 = plt.subplots()
> ax2 = ax1.twiny()
> ax1.plot(np.random.randn(50), 'gs')
> ax2.plot(np.random.randn(50), 'bo')
> ax1.set_title('Test Title')
> ax2.xaxis.tick_bottom()
> plt.show()
>
> Does that help?
> -paul
>
>
--
__
Jonathan D. Slavin Harvard-Smithsonian CfA
[email protected] 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
__
--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] append to or concatenate PathCollection objects?
Hi, I'm wondering if there is some straightforward way to combine two PathCollection objects to create a new PathCollection object. My goal is to include two points that use different axes (one twin'ed to the other) into a single legend item (different point types, same label). Each call to scatter creates a new PathCollection object. If I could just combine two (or more) PathCollection objects -- either extending them or concatenating or whatever -- then I could give that to legend and it would work correctly. But it's not clear to me how I can do that. I tried providing the two objects as a tuple to legend, but it doesn't work (only point characteristics of one of them is used). Really, I think this should be easier -- both the combining of such objects (which after all, are collections) and providing legend with simple arguments to produce what you want. As far as I can tell I can't just tell leged directly the symbol type(s) and colors of point(s) per each label. Though in general the automatic method whereby you provide the object to the legend is nice and easy, a more crude and direct way would be a good option for special cases. Jon -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnnow-d2d ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] append to or concatenate PathCollection objects?
Sterling,
I have version 1.2.0. I read the legend guide. Which thing should be
possible? If you mean giving the points as a tuple, here's some simple
test code:
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
p1 = ax.scatter([0.1],[0.5],c='r',marker='s')
p2 = ax.scatter([0.3],[0.2],c='b',marker='o')
l = ax.legend((p1,p2),['points'],scatterpoints=2)
plt.show()
I get a legend with only red squares. What I want is a legend line with
a red square and a blue circle. I can get points with different colors
if I do:
p1 = ax.scatter([0.1,0.3],[0.5,0.2],c=('r','b'),marker='s')
l = ax.legend(['points'],scatterpoints=2)
(though as far as I can tell, you can't have a sequence of marker
types).
Jon
On Wed, 2013-01-23 at 09:57 -0800, Sterling Smith wrote:
> Jon,
>
> What version of matplotlib do you have? According to
> http://matplotlib.org/users/legend_guide.html
> what you say should be possible in 1.2.0.
>
> -Sterling
>
> On Jan 23, 2013, at 9:35AM, Jonathan Slavin wrote:
>
> > Hi,
> >
> > I'm wondering if there is some straightforward way to combine two
> > PathCollection objects to create a new PathCollection object. My goal
> > is to include two points that use different axes (one twin'ed to the
> > other) into a single legend item (different point types, same label).
> > Each call to scatter creates a new PathCollection object. If I could
> > just combine two (or more) PathCollection objects -- either extending
> > them or concatenating or whatever -- then I could give that to legend
> > and it would work correctly. But it's not clear to me how I can do
> > that. I tried providing the two objects as a tuple to legend, but it
> > doesn't work (only point characteristics of one of them is used).
> >
> > Really, I think this should be easier -- both the combining of such
> > objects (which after all, are collections) and providing legend with
> > simple arguments to produce what you want. As far as I can tell I can't
> > just tell leged directly the symbol type(s) and colors of point(s) per
> > each label. Though in general the automatic method whereby you provide
> > the object to the legend is nice and easy, a more crude and direct way
> > would be a good option for special cases.
> >
> > Jon
> > --
> > __
> > Jonathan D. Slavin Harvard-Smithsonian CfA
> > [email protected] 60 Garden Street, MS 83
> > phone: (617) 496-7981 Cambridge, MA 02138-1516
> > cell: (781) 363-0035 USA
> > __
> >
> >
> > --
> > Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> > MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> > with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> > MVPs and experts. ON SALE this month only -- learn more at:
> > http://p.sf.net/sfu/learnnow-d2d
> > ___
> > Matplotlib-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
__
Jonathan D. Slavin Harvard-Smithsonian CfA
[email protected] 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
__
--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plot with a shared y axis with two different x axes oriented in opposite directions.
Hi Darhas, How did you invert the axis? I find that it works for me to do: ax.plot(x1,y1) ax2 = ax.twiny() ax2.plot(x2,y2) ax2.invert_xaxis() Jon On Wed, 2013-01-30 at 16:45 +, Dharhas Pothina wrote: > Hi All, > > > I'm trying to recreate some plots from a old 1970's era report. This > is a single plot with an elevation-capacity curve and an > elevation-area curve overlaid on top of each other. > > > The plot needs to have a shared y-axis (elevation). The > elevation-capacity curve has an x-axis along the bottom that goes left > to right. The elevation-area curve has a x-axis with a different scale > that goes right to left along the top. > > > I've tried using twiny and reversing the second x axis but that ends > up reversing both. Any help would be appreciated. I've attached a low > res image of one of the original plots for reference. > > > Thanks, > > > - dharhas -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_jan ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Feedback on an implementation of a matlab-ish "datacursor"
Nevermind on my earlier question on artists and using datacursor. I figured that one out. What I did was basically (after creating the image and contours): artist = gca().images datacursor(artist) and it worked! Jon On Wed, 2013-03-13 at 15:50 -0400, Jonathan Slavin wrote: > Joe, > > Thank you! I will especially use it to get the z value in images. I > started to try to do something like this once but never finished. > > One thing I'm having a bit of trouble with is providing an artist as an > argument. The reason I wanted to do that is to look only at the values > for the image and not those for the contours drawn on the image. How > does that work exactly? > > As a side note, I thought that I had found a bug because an I was > looking at image would, in some places, print only the x and y values > but not the z value. Then I realized it was printing the values for a > contour that I had made invisible by setting its edgecolor to 'None'. > This was because the contour created had two parts and I only wanted to > show one of them. Anyone know a different way to do that? > > Regards, > Jon > > On Tue, 2013-03-12 at 22:58 -0500, Joe Kington wrote: > > I recently got around to polishing up a snippet I've been using for > > quite awhile. https://github.com/joferkington/mpldatacursor/ and I > > was hoping to get some feeding on the current implementation. > > > > > > "mpldatacursor" allows a user to easily click on an artist and display > > a customizable, interactive pop-up box displaying information about > > the selected artist (e.g. x & y, label, z for images and collections, > > etc). It's a stand-alone module (and in pypi), but you could also > > just download the examples directory from github and copy the > > mpldatacursor.py file into it to try things out. > > > > > > A few key questions: > > > > 1. Is this something that anyone else finds useful? > > > > 2. Does it seem intuitive? > > > > 3. Does the implementation seem flexible enough for most needs? > > (Note that any additional kwargs are passed on to annotate to > > create the "data cursor", so the appearance of the box is > > customizable through annotation kwargs.) > > > > 4. Are there any obvious features missing? > > > > 5. Any suggestions? (especially better name suggestions...) > > > > If it is something that other people find useful, I'd be happy to > > submit a pull request to incorporate it into matplotlib. (If I did, > > it would probably be best to drop the HighlightDataCursor class, as > > its limited in what it can do.) > > > > Thanks a bunch! > > > > -Joe > > > > > > > -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Feedback on an implementation of a matlab-ish "datacursor"
Joe, Thank you! I will especially use it to get the z value in images. I started to try to do something like this once but never finished. One thing I'm having a bit of trouble with is providing an artist as an argument. The reason I wanted to do that is to look only at the values for the image and not those for the contours drawn on the image. How does that work exactly? As a side note, I thought that I had found a bug because an I was looking at image would, in some places, print only the x and y values but not the z value. Then I realized it was printing the values for a contour that I had made invisible by setting its edgecolor to 'None'. This was because the contour created had two parts and I only wanted to show one of them. Anyone know a different way to do that? Regards, Jon On Tue, 2013-03-12 at 22:58 -0500, Joe Kington wrote: > I recently got around to polishing up a snippet I've been using for > quite awhile. https://github.com/joferkington/mpldatacursor/ and I > was hoping to get some feeding on the current implementation. > > > "mpldatacursor" allows a user to easily click on an artist and display > a customizable, interactive pop-up box displaying information about > the selected artist (e.g. x & y, label, z for images and collections, > etc). It's a stand-alone module (and in pypi), but you could also > just download the examples directory from github and copy the > mpldatacursor.py file into it to try things out. > > > A few key questions: > > 1. Is this something that anyone else finds useful? > > 2. Does it seem intuitive? > > 3. Does the implementation seem flexible enough for most needs? > (Note that any additional kwargs are passed on to annotate to > create the "data cursor", so the appearance of the box is > customizable through annotation kwargs.) > > 4. Are there any obvious features missing? > > 5. Any suggestions? (especially better name suggestions...) > > If it is something that other people find useful, I'd be happy to > submit a pull request to incorporate it into matplotlib. (If I did, > it would probably be best to drop the HighlightDataCursor class, as > its limited in what it can do.) > > Thanks a bunch! > > -Joe > > > -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] set limits not obeyed for stacked plots when set_aspect('equal') used
Hi all,
I've run across a minor but annoying bug. It can be demonstrated pretty
simply:
fig, ax = plt.subplots(2,1,sharex=True,figsize=(7.,7.))
fig.subplots_adjust(hspace=0.0)
x = 4.25*(np.arange(6.) - 2.5)/10.
y = 0.6*x/max(x)
ax[0].plot(x,y)
ax[0].set_xlim(-1.2,1.2)
ax[0].set_aspect('equal')
ax[1].plot(x,y)
ax[0].set_ylim(-0.6,0.6)
ax[1].set_ylim(-0.6,0.6)
ax[1].set_aspect('equal')
plt.show()
The problem is that the y limits on the two plots are slightly different
from those set:
ax[1].get_ylim()
(-0.61935483870967734, 0.61935483870967734)
and doing a set_ylim doesn't have any effect. This seems to be caused
by the set_aspect('equal'), since removing it results in plots with the
correct limits -- but aspect that is not quite equal. It is affected by
the figsize parameter in the call to subplots. It seems I can get the
correct y limits and aspect if I keep the set_aspect('equal') and fiddle
with the figsize. But that certainly doesn't seem to be a desirable
behavior. Ideally, the set_ylim (or set_xlim) would be respected as
well as the apect ratio and extra blank space around the figure would be
added as needed to fit the figsize.
By the way, using no figsize argument to subplots results in y limits
even smaller than the data limits. Also, this problem does not occur
for single (non-stacked) plots and the use of subplots_adjust also does
not seem to affect the problem. I'm using matplotlib 1.2.0
I did notice that this issue is similar to that discussed in this
thread:
http://www.mail-archive.com/[email protected]/msg05783.html
Regards,
Jon
--
__
Jonathan D. Slavin Harvard-Smithsonian CfA
[email protected] 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
__
--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] set limits not obeyed for stacked plots when set_aspect('equal') used
Eric,
I don't see it that way. Specifying an equal aspect ratio just means
that I want the scaling of the axes to the same. Then specifying the
data limits gives the overall scaling of the figure effectively. This
works perfectly well for a single set of axes. The bounding space is
allotted so that it all works. The problem only arises when I have the
figures stacked. Then it seems that the bounding space becomes fixed
for some reason and instead the axis limits are "what gives" instead of
the space around the axes.
By the way, the adjustable='box-forced' option to set_aspect generates
an exception,
ValueError: adjustable must be "datalim" for shared axes
Jon
On Wed, 2013-03-20 at 11:25 -1000, Eric Firing wrote:
> On 2013/03/20 8:57 AM, Jonathan Slavin wrote:
> > Hi all,
> >
> > I've run across a minor but annoying bug. It can be demonstrated pretty
> > simply:
> >
> > fig, ax = plt.subplots(2,1,sharex=True,figsize=(7.,7.))
> > fig.subplots_adjust(hspace=0.0)
> > x = 4.25*(np.arange(6.) - 2.5)/10.
> > y = 0.6*x/max(x)
> > ax[0].plot(x,y)
> > ax[0].set_xlim(-1.2,1.2)
> > ax[0].set_aspect('equal')
> > ax[1].plot(x,y)
> > ax[0].set_ylim(-0.6,0.6)
> > ax[1].set_ylim(-0.6,0.6)
> > ax[1].set_aspect('equal')
> > plt.show()
> >
> > The problem is that the y limits on the two plots are slightly different
> > from those set:
>
> I think the problem is that you are trying to specify too many things:
> you are specifying the box dimensions when you make the axes, then you
> are specifying xlim, and then you are specifying ylim, but then you are
> asking for a 1:1 aspect ratio. Something has to give! The aspect ratio
> handling is designed to provide the specified aspect ratio under a wide
> range of circumstances, including zooming and panning, and to do that,
> it has to be able to change something. You can choose to let the box
> dimensions be changeable, or the data limits.
>
> If you want to fix the data limits, then you have to make the box
> adjustable. This can cause problems with shared axes, but you can try
> it with ax[0].set_aspect('equal', adjustable='box-forced').
>
> Eric
>
> > ax[1].get_ylim()
> > (-0.61935483870967734, 0.61935483870967734)
> > and doing a set_ylim doesn't have any effect. This seems to be caused
> > by the set_aspect('equal'), since removing it results in plots with the
> > correct limits -- but aspect that is not quite equal. It is affected by
> > the figsize parameter in the call to subplots. It seems I can get the
> > correct y limits and aspect if I keep the set_aspect('equal') and fiddle
> > with the figsize. But that certainly doesn't seem to be a desirable
> > behavior. Ideally, the set_ylim (or set_xlim) would be respected as
> > well as the apect ratio and extra blank space around the figure would be
> > added as needed to fit the figsize.
> >
> > By the way, using no figsize argument to subplots results in y limits
> > even smaller than the data limits. Also, this problem does not occur
> > for single (non-stacked) plots and the use of subplots_adjust also does
> > not seem to affect the problem. I'm using matplotlib 1.2.0
> >
> > I did notice that this issue is similar to that discussed in this
> > thread:
> > http://www.mail-archive.com/[email protected]/msg05783.html
> >
> > Regards,
> > Jon
> >
>
>
>
--
__
Jonathan D. Slavin Harvard-Smithsonian CfA
[email protected] 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
__
--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] set limits not obeyed for stacked plots when set_aspect('equal') used
Hmm. It seems that the adjustable='box-forced' option to set_aspect
does work. I don't know what went wrong the first time I tried it
(probably a typo). So that solves my problem. Thanks Eric.
It does seem to me that this should be the default behavior, though I
can appreciate the difficulty with panning and zooming.
Jon
On Wed, 2013-03-20 at 18:16 -0700, Brendan Barnwell wrote:
>
> On 2013-03-20 14:25, Eric Firing wrote:
> > > On 2013/03/20 8:57 AM, Jonathan Slavin wrote:
> >> >> Hi all,
> >> >>
> >> >> I've run across a minor but annoying bug. It can be
> demonstrated pretty
> >> >> simply:
> >> >>
> >> >> fig, ax = plt.subplots(2,1,sharex=True,figsize=(7.,7.))
> >> >> fig.subplots_adjust(hspace=0.0)
> >> >> x = 4.25*(np.arange(6.) - 2.5)/10.
> >> >> y = 0.6*x/max(x)
> >> >> ax[0].plot(x,y)
> >> >> ax[0].set_xlim(-1.2,1.2)
> >> >> ax[0].set_aspect('equal')
> >> >> ax[1].plot(x,y)
> >> >> ax[0].set_ylim(-0.6,0.6)
> >> >> ax[1].set_ylim(-0.6,0.6)
> >> >> ax[1].set_aspect('equal')
> >> >> plt.show()
> >> >>
> >> >> The problem is that the y limits on the two plots are slightly
> different
> >> >> from those set:
> > >
> > > I think the problem is that you are trying to specify too many
> things:
> > > you are specifying the box dimensions when you make the axes,
> then you
> > > are specifying xlim, and then you are specifying ylim, but then
> you are
> > > asking for a 1:1 aspect ratio. Something has to give! The
> aspect ratio
> > > handling is designed to provide the specified aspect ratio under
> a wide
> > > range of circumstances, including zooming and panning, and to do
> that,
> > > it has to be able to change something. You can choose to let the box
> > > dimensions be changeable, or the data limits.
>
> If I understand right, though, in this case what should give is the
> spacing around the axes but inside the figure (as suggested in the
> original post). You should be able to fix the aspect ratio of the
> *axes* and also the dimensions of the *figure*, and let the slack be
> taken up by blank space around the axes. It would still be possible
> for the dimensions of the axes box to change, just not their aspect
> ratio (i.e., zooming in on an oblong region would just result in a lot
> of blank space).
>
> -- Brendan Barnwell "Do not follow where the path may lead. Go,
> instead, where there is no path, and leave a trail." --author unknown
>
>
>
--
__
Jonathan D. Slavin Harvard-Smithsonian CfA
[email protected] 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
__
--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plot resolution of axes
Hi Miriam,
This case is a simple one for setting the axis ratios. You want to set
the aspect ratio to equal:
gca().set_aspect('equal')
after making your plot
Jon
On Mon, 2013-03-25 at 16:06 +0100, Miriam Degginger wrote:
> Hi all,
>
> I am working on a correlation chart with pyplot for a monitoring web
> tool. The plot is looking good, but only the strange resolution of axes
> disturbs the view.
>
> In a simple correlation plot, e.g. I want to compare two temperature
> sensors, I expect a line who divides the picture in two halves with an
> angle of 45° (optimal correlation R²=1). That feels natural and you can
> see whether the both sensors correlate or not without a deeper look at
> the exact values. But pyplot shows me a chart, where the x-axis's tick
> interval is larger (108 pixel) than the y-axis's tick interval (77
> pixel). In attachment you can see my example.
>
> How can I manipulate the axes that they show the same pixel resolution?
>
> I hope I make my case clear. If more information is needed, please tell me.
>
> Thank you very much in advance!
>
> Miriam D.
--
__
Jonathan D. Slavin Harvard-Smithsonian CfA
[email protected] 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
__
--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] tight_layout and ImageGrid
Hi, I wrote a short routine to look through a set of images that result from slightly different processing of the same data. I want to compare three different images and be able to zoom them all in the same way and then move onto the next set of three. The best way that I've found to do that so far involves using mpl_toolkits.axes_grid1.ImageGrid. It all works fine. I found that to get the most image on screen at once, using the tight_layout=True argument to plt.figure gives excellent results. My one question is that I get the following warning: WARNING: This figure includes Axes that are not compatible with tight_layout, so its results might be incorrect. [matplotlib.figure] As I say, the results are good, so it's not really a problem, but I do wonder about the source of the warngin -- and whether re-using the code in a different way in the future could lead to problems. So, my question is: what is the problem pointed to by the warning and how could I avoid it (while still getting the same good results)? Regards, Jon -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. This 200-page book is written by three acclaimed leaders in the field. The early access version is available now. Download your free book today! http://p.sf.net/sfu/neotech_d2d_may ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Squashed axes with AxesGrid
Matthias,
It's clear to me why apect='equal' doesn't work for you. That option
means to give the axes equal scaling -- i.e., the ratio of length in
axis units to length in the plot is the same for both axes, so that an
axis that goes from 0 to 1 will be twice as long as one that goes from 0
to 0.5. What is quite unclear to me is why aspect=2 should give a
result like it does. You can get the right image, though wrong tick
labeling, if you omit the extent argument to imshow.
Jon
On Thu, 2013-05-16 at 12:43 -0700, Matthias Flor wrote:
> Hi all,
>
> it seems that I am experiencing the same problem here with imshow (rather
> than scatter) and AxesGrid. But calling imshow with aspect=False does not do
> the trick for me.
> I am trying to have two imshow subplots next to each other and a single
> colorbar at the right. The data underlying the imshow's have different x-
> and y-ranges but I want the x- and y-axis to have an aspect ratio of 1 (i.e.
> each imshow should produce a square). I've tried aspect=False,
> aspect='equal', and explicitely setting aspect=2 which should be the correct
> value. See the three images below the code example.
>
> I've also tried Grid instead of AxesGrid as suggested but I didn't manage to
> achieve good results with the colorbar in that case.
>
> I'd appreciate any help,
>
> Matthias
>
>
>
> Here's a more or less minimal code example:
> #
> import numpy as np
> import numpy.random as npr
> from scipy.interpolate import griddata
> import matplotlib.pyplot as plt
> from mpl_toolkits.axes_grid1 import AxesGrid
>
> fig = figure(1, figsize=[12,10])
>
> grid = AxesGrid(fig, 111,
> nrows_ncols = (1, 2),
> axes_pad = 0.2,
> share_all = False,
> label_mode = 'L',
> cbar_location = 'right',
> cbar_mode = 'single',
> cbar_pad = 0.2
> )
>
> for i in range(2):
> xmin, xmax = 0., 1.
> ymin, ymax = 0., 0.5
> zmin, zmax = -1., 1.
>
> # generate random data:
> N = 100
> X = xmin + (xmax-xmin)*npr.random((N,)) # x_i in [0, 1]
> Y = ymin + (ymax-ymin)*npr.random((N,)) # y_i in [0, 0.5]
> Z = zmin + (zmax-zmin)*npr.random((N,)) # z_i in [-1, 1]
>
> # generate griddata for imshow plot:
> numspaces = np.sqrt(N)
> xi = linspace(xmin, xmax, numspaces)
> yi = linspace(ymin, ymax, numspaces)
> zi = griddata((X, Y), Z, (xi[None,:], yi[:,None]), method='nearest')
> norm = matplotlib.colors.normalize(vmin=zmin, vmax=zmax)
>
> ax = grid[i]
> im = ax.imshow(zi,
> extent = [xmin,xmax,ymin,ymax],
> norm = norm,
> vmin = zmin,
> vmax = zmax,
> origin = 'lower',
> aspect = 'equal', # or False, or 'auto', or 2, or ...
> interpolation = 'nearest')
>
> ax.grid(False)
> ax.set_xlabel('x')
> ax.set_ylabel('y')
>
> # add a colorbar:
> cbar = plt.colorbar(im, cax=grid.cbar_axes[0])
> cbar.ax.set_ylabel('color level')
>
>
> And here are the three resulting images:
>
> aspect='equal':
>
>
> aspect=False:
>
>
> aspect=2.:
>
>
>
>
> --
> View this message in context:
> http://matplotlib.1069221.n5.nabble.com/Squashed-axes-with-AxesGrid-tp40699p41075.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
--
__
Jonathan D. Slavin Harvard-Smithsonian CfA
[email protected] 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
__
--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to make 3-D axes/grid more visible?
I've been using Axes3D to make plots and I like the output very much -- with the one exception being the faintness of the 3-D grid that is put in the background. The light gray used is quite difficult to see. Is there some way to specify the color of the grid and/or background? I'd be satisfied with having the grid lines darker. I've been looking through the axes3d.py file under mpl_toolkits/mplot3d but haven't figured it out yet. By the way, anyone looking to specify an initial non-default orientation for the grid, I discovered that you can do this when instantiating your Axes3D object this way: ax = Axes3D(fig,elev=e,azim=a) where e and a are the elevation about the x-axis and azimuthal rotation about the z-axis (both in degrees). 0 azimuthal rotation has the y-z plane in the plane of the screen; azim. rotation is defined as clockwise as viewed from above. -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] selecting part of a contour to plot
To all: I'm making a plot with an image and a contour on it. I use only one level in the call to contour, but it results in two distinct contours, an inner closed one and an outer open one. I want to plot only the outer piece. How might I go about that? I've been looking at the properties of the ContourSet object returned by the call to contour but can't find anything useful yet. Is there an attribute of ContourSet objects that contains the (x,y) values for the contour? Is there some way to see that a ContourSet object has separate pieces? Any help would be appreciated. Thanks, Jon -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] selecting part of a contour to plot
Thanks to Benjamin Root and Jae-Joon Lee for their responses. The solution that I had come up with in the mean time is similar to Jae-Joon's suggestion. I did: c = contour(z,level,colors='k') xy = c.collections[0].get_paths()[0].vertices # produces (N,2) array of points plot(xy[:,0],xy[:,1],'w') c.collections[0].get_paths() returns a list of Path objects. These have the attribute vertices which contains the values used to draw the contour. Jae-Joon's method is a bit more straightforward than mine, though it's nice to know where those contour paths are stored. Jon On Tue, 2010-06-22 at 22:40 -0400, Jae-Joon Lee wrote: > contour creates list of LineCollection objects (per each level I > suppose) which is stored in "collections" attribute. For example, > > cntr = contour(A, levels) > > then > > cntr.collections[i] is a LineCollection objects that is associated > with levels[i]. > > And you can change colors of each line in the LineCollection object > with set_edgecolors method. > > So, assuming that there is two contour lines for the first level. > > cntr.collections[0].set_edgecolors(["none", "r"]) > > will change the color of the first contour to "none" (i.e., not drawn) > and the second one to red. > > But you need to figure out which one is the one you want. > > IHTH, > > -JJ > > > On Tue, Jun 22, 2010 at 2:46 PM, Jonathan Slavin > wrote: > > To all: > > > > I'm making a plot with an image and a contour on it. I use only one > > level in the call to contour, but it results in two distinct contours, > > an inner closed one and an outer open one. I want to plot only the > > outer piece. How might I go about that? I've been looking at the > > properties of the ContourSet object returned by the call to contour but > > can't find anything useful yet. Is there an attribute of ContourSet > > objects that contains the (x,y) values for the contour? Is there some > > way to see that a ContourSet object has separate pieces? > > > > Any help would be appreciated. > > > > Thanks, > > Jon > > > > > > -- > > ThinkGeek and WIRED's GeekDad team up for the Ultimate > > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > > lucky parental unit. See the prize list and enter to win: > > http://p.sf.net/sfu/thinkgeek-promo > > ___ > > Matplotlib-users mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting open symbols
Tinne, Thanks. I think I had tried that but with mfc=None -- that is without None in quotes as if it were a string. I have to say it's a bit odd to have it in quotes since generally it is a different data type entirely (None type). Jon On Fri, 2010-08-20 at 17:12 +0200, Tinne De Laet wrote: > Hi Jonathan, > > On Fri, Aug 20, 2010 at 16:29, Jonathan Slavin > wrote: > > To all: > > > > I'm wondering if there is any way to make plots with open symbols, e.g. > > a circle. I know how to use markers that look open, e.g. by doing > > something like, > > plot(x,y,marker='o',mfc='w') > > They are white in the center, but they're not really open since they > > block out whatever is behind them. I tried using a color with > > transparency, say alpha=0.1 or something (mfc=(1.,1.,1.,0.1)) but that > > didn't work. What I have in mind is illustrated in the attached plot, > > which I made some time ago in IDL. Is there an easy way to define your > > own markers for plotting? > > just use mfc='None' > > > Tinne -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] CMYK images
This is starting to get off topic from matplotlib, but it is relevant to creating good EPS figures... When using ImageMagick to transform from to an EPS, your results will be much improved by using the parameter "-density 288". This increases the resolution (and thus results in a much bigger file). I find this is adequate for producing publication quality plots. > > Quick warning about ImageMagick and EPS files (and any other > > vector-based graphics format)... > > > > ImageMagick is a raster-based system. When it loads a vector-based > > graphic, it implicitly rasterizes it, performs the requested > > operations, and then outputs the file format. So, even if you > > output the result as a EPS file, you would have lost all > > vector-based info (like text and lines). The result looks horrible. -- Sell apps to millions through the Intel(R) Atom(Tm) Developer Program Be part of this innovative community and reach millions of netbook users worldwide. Take advantage of special opportunities to increase revenue and speed time-to-market. Join now, and jumpstart your future. http://p.sf.net/sfu/intel-atom-d2d ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Line changes color along its length
This is of interest to me, and it's nice to know that this is do-able with matplotlib, but like many of the examples, I find it sorely lacking in documentation. For example, why are the points and segments arrays shaped so specifically the way they are? Why the call to set_array? Could the same thing be accomplished with a call to set_facecolor? I hope the same things can be accomplished in a more straightforward way. Any illumination on these points would be appreciated. Jon > On Tue, Sep 7, 2010 at 6:50 PM, Brian Larsen > wrote: > > Hey all, > > I think I know the answer here as "no" or something, but > say I have a curve > > I want to plot and I want the color to change along the > curve to denote the > > 3rd variable is there anyway to do this is matplotlib? > > What I mean is take the simple plot > > from pylab import * > > plot(range(30), range(30, 60), lw=10) > > and say that the 3rd variable is > > inten = [val ** 2 for val in range(30)] > > then can the line change color along its length according to > a specified > > color table? > > In IDL this is done by just giving a color array with the > same length as the > > data then the line changes with the current colortable. > > Try this: > > > http://matplotlib.sourceforge.net/examples/pylab_examples/multicolored_line.html > > Ryan > > -- > Ryan May > Graduate Research Assistant > School of Meteorology > University of Oklahoma -- This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] convert figure from color to BW/grayscale
A non-matplotlib way to do this is to use ImageMagick or GraphicsMagick: gm convert -colorspace Gray color_image.png bw_image.png in GraphicsMagick or using the ImageMagick routine "convert": convert -colorspace Gray color_image.png bw_image.png I think it works on a wide variety of image formats. Jon > Hello, > I need to prepare two versions of figures: color and BW(Black&White). > Is there an easy way to produce just the colored version and than use > some command or script to turn it to BW or grayscale? > I thought that converting from color to BW really means: "in all > object in the figure, turn any color that is not white to black". > Is there an easy way to implement this? > > Thanks > Eli -- Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to find out the extend of the actual image in pixels
This is interesting. It seems that the event.x, event.y values are for the entire figure area rather than limited to the image. Anyone know how to get the image values instead? Also, I wonder how one might get the values of the pixels (i.e. image value) at the pixels that you click on. One more thing -- is there a way to make the cursor be a full plot window cross -- graphically like: -- || | || | || | ||-| || | || | -- It makes it easier to align with the axes sometimes (the IDL astronomy library has a routine called rdplot that does this). Jon -- Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] scientific notation in ticklabels for linear plot
Hi,
I'm wondering if there's some relatively automatic way to have the
ticklabels to come out in scientific notation for an axis that uses a
linear scale (and has a range that warrants scientific notation)? For
example, an axis that goes from 0 to 2.E18 by default uses the labels 0,
0.5, 1.0, 1.5, 2.0 and puts 1e18 at the end of the axis. To me this is
unappealing. 1e18 is a computer programming way to write the 10^{18} (in
LaTeX formatting). In IDL the ticklabels are 5.0x10^{17}, 1.0x10^{18},
1.5x10^{18}, 2.0x10^{18}. This is one instance where I think IDL gets
it right and matplotlib gets it wrong. So, as far as I can tell, one
can give the ticklabels by hand, and so I could achieve my desired
labels that way, but it'd be nice to have a more automatic way to do it.
Searching the examples, I've come up empty so far. I would also
advocate changing the default format for labeling axes that fall in this
category. Do the developers have any opinions on this?
Regards,
Jon
--
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] scientific notation in ticklabels for linear plot
I think that'd be fine -- i.e. the option of \cdot or \times (though in
the gmane preview the dot looks a bit low). In the mean time, I came up
with the method below that worked for my purpose.
Jon
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import FuncFormatter
def scinot(x,pos=None):
if x == 0:
s = '0'
else:
xp = int(np.floor(np.log10(np.abs(x
mn = x/10.**xp
# Here we truncate to 2 significant digits -- may not be enough
# in all cases
s = '$'+str('%.1f'%mn) +'\\times 10^{'+str(xp)+'}$'
return s
x = np.linspace(0.,2.,10)*1.E18
y = 2.*(x/1.E18) - 1.
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x,y)
ax.xaxis.set_major_formatter(FucFormatter(scinot))
plt.show()
On Tue, 2010-10-19 at 15:30 -0400, David Pine wrote:
> I like the times symbol but others prefer the dot (which I missed in the
> gmane preview!). So I like your suggestion of providing an option to use
> either \cdot or \times.
>
> David
>
> On Oct 19, 2010, at 3:23 PM, Friedrich Romstedt wrote:
>
> > What about inserting \cdot, that's the scientific notation I do prefer?
> >
> > If I'm not mistaken that's what I did that time, might be unreadable
> > in the preview? I checked, when you look close you see the dot in
> > gmane preview.
> >
> > We can make this customisable, with \times as an alternative option.
> >
> > Friedrich
>
--
__
Jonathan D. Slavin Harvard-Smithsonian CfA
[email protected] 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
__
--
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] scientific notation in ticklabels for linear plot
Friedrich, Our e-mails crossed. I don't think the numbers need to have the same exponent. I would go with (d) as my example does. The more difficult part to my mind is the number of significant digits to use. The current code that determines whether to use an offset or not must look at the number of significant digits needed to represent the ticklabels. To me what would be optimal is to, by default, use scientific notation (when the ticklabel numbers are larger or smaller than some range, say 10^3 and 10^-3) except when an offset is called for, say more than 3 significant digits are needed to represent the ticklabel numbers in scientific notation. Jon On Tue, 2010-10-19 at 21:41 +0200, Friedrich Romstedt wrote: > 2010/10/19 David Pine : > > I like the times symbol but others prefer the dot (which I missed in the > > gmane preview!). So I like your suggestion of providing an option to use > > either \cdot or \times. > > Okay, I'll try to look into it next week, is that okay with you both? > I don't want to do it now since there might be more under the hood, > just thinking about automatic exponent choice, I have a module for > that, but it needs to pick up all the range the formatter spans over. > > I'd say we also have use for three other configs of the exponent choice: > a) largest > b) smallest > c) mean > d) dynamic > exponent. > > Examples: > (a) 0.001 10^2 ... 2.0 10^2 > (b) 1.0 10^-1 ... 200.0 10^-1 > (c) 0.01 10^1 ... 20.0 10^1 > (d) 1.0 10^-1 ... 2.0 10^2 > Sorry if there's some mistake but you see the principle. > > Also the number of digits present need to be configurable ... enough for a > week. > > I favour (c) as the default, and 2 digits precision. > > Friedrich -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] getting minor ticks by default
Is there some way to get minor tick marks on plots by default? I can do: plt.minorticks_on() easily enough, but it seems that there is no setting I can put in my matplotlibrc file that will give me them by default. Is that right? Jon -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] how to scale colorbar size to image size?
Hi all: I'm looking for a simple way to scale a color bar so it will be the same height as the image. It seems to work automatically if the image is at least as tall as it is wide, but when it is wider than tall it seems to scale to the width rather than height. (Shouldn't the default behavior be to scale to height if the colorbar is vertical and width if its horizontal?) One approach that I found at one point was something like this: fig = plt.figure(figsize=(11,5)) cax = fig.add_axes([0.9,0.1,0.01,0.8]) # axes for colorbar ax = plt.subplot(111) im = ax.imshow(image) fig.colorbar(im,cax=cax) but even with this method it seems that tweaking the figsize and add_axes arguments. I've also fiddled with the shrink and fraction keywords and have managed to get good results, but it seems so ad hoc. Is there a better way? Jon -- Xperia(TM) PLAY It's a major breakthrough. An authentic gaming smartphone on the nation's most reliable network. And it wants your games. http://p.sf.net/sfu/verizon-sfdev ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] imshow in Axes3D?
Hi, I would like to create a plot with a series of parallel 2-D slices in order to illustrate 3-D data. I got excited when I saw the example of translucent bar plots, which is similiar in some ways to what I had in mind. But it seems that there is no imshow method in Axes3D. How hard would that be to add? (By the way, I do know about mayavi and have used it, but there are things about it that make it somewhat difficult to work with.) Jon -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Achieve unprecedented app performance and reliability What every C/C++ and Fortran developer should know. Learn how Intel has extended the reach of its next-generation tools to help boost performance applications - inlcuding clusters. http://p.sf.net/sfu/intel-dev2devmay ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] forcing prompt draw
To all:
I'm doing a series of fits and want to display the results of each in a
figure before I go to the next one. I currently do roughly something
like this (with a lot left out):
import matplotlib.pyplot as plt
plt.ion()
fig = plt.gcf()
for obsid in obsids:
plt.cla()
fig = plt.gcf()
ax = fig.add_axes([0.15,0.1,0.8,0.6])
ax.plot(x,y)
plt.draw()
ans = raw_input('continue? ')
if ans == 'n':
break
This works, sort of, except that the first plot is not shown until the
second time I hit the raw_input line. So my question is, is there any
way to make the figure display immediately when the draw() is executed?
Jon
--
__
Jonathan D. Slavin Harvard-Smithsonian CfA
[email protected] 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
__
--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense..
http://p.sf.net/sfu/splunk-d2d-c1
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] forcing prompt draw
I tried the suggested clean-up but saw no difference in performance. I
left out a crucial piece of information, I think, in my earlier message.
The delay in drawing occurs when I'm running the code from within
ipython, invoked with the -pylab flag. When I run it directly from the
command line, I get no such delay. I presume this is backend dependent.
For my current purposes, just running it directly from the command line
(i.e. something like: % python do_fits.py) works for me. The ability to
interactively examine variables, as one can when running within ipython,
would be nicer, however.
Jon
> On 06/24/2011 04:03 AM, Jonathan Slavin wrote:
> > import matplotlib.pyplot as plt
> > plt.ion()
> > fig = plt.gcf()
> > for obsid in obsids:
> >
> > plt.cla()
> > fig = plt.gcf()
> > ax = fig.add_axes([0.15,0.1,0.8,0.6])
> > ax.plot(x,y)
> > plt.draw()
> > ans = raw_input('continue? ')
> > if ans == 'n':
> > break
>
> The behavior may depend on mpl version and backend, but with
> 1.0.1 or
> later, I think something like what you have will work with a
> little
> cleanup, e.g.:
>
> import matplotlib.pyplot as plt
> import numpy as np
>
> plt.ion()
> fig = plt.gcf()
> ax = fig.add_axes([0.15,0.1,0.8,0.6])
> for i in range(3):
> ax.cla()
> ax.plot(np.random.rand(10))
> plt.draw()
> raw_input("hit a key to proceed")
>
>
> Eric
--
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] mathtext in eps figures doesn't come out in pdf
Hi all, I've been making figures for a paper I'm writing (to be submitted to the ApJ). I'm using LaTeX and so need to use encapsulated PostScript for the figures. The problem is that when the paper is translated to pdf from PostScript, the mathtext in the figures disappears. The reason that I think this is a matplotlib issue is that it's never happened to me with eps figures created in different ways. It's clear that this must be related to fonts, but I'm not sure how to get around it. Should I set text.usetex to True? I have a feeling this issue must have come up before, but I haven't found anything obviously pertinent in the mailing list archives. Jon -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] mathtext in eps figures doesn't come out in pdf
Setting test.usetex to True solved this problem. The only drawback is that the font used for numbers and that used for axis labels is different and looks a bit odd. I'm sure the fix for that is not too difficult, however. Jon On Wed, 2011-08-17 at 14:09 +0900, Jae-Joon Lee wrote: > Can you post an output eps file so that we can take a look? > Regards, > > -JJ > > > > On Wed, Aug 17, 2011 at 5:52 AM, Jonathan Slavin > wrote: > > Hi all, > > > > I've been making figures for a paper I'm writing (to be submitted to the > > ApJ). I'm using LaTeX and so need to use encapsulated PostScript for > > the figures. The problem is that when the paper is translated to pdf > > from PostScript, the mathtext in the figures disappears. The reason > > that I think this is a matplotlib issue is that it's never happened to > > me with eps figures created in different ways. It's clear that this > > must be related to fonts, but I'm not sure how to get around it. Should > > I set text.usetex to True? I have a feeling this issue must have come > > up before, but I haven't found anything obviously pertinent in the > > mailing list archives. > > > > Jon > > > > > > -- > > Get a FREE DOWNLOAD! and learn more about uberSVN rich system, > > user administration capabilities and model configuration. Take > > the hassle out of deploying and managing Subversion and the > > tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 > > ___ > > Matplotlib-users mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] solution for eps figures and pdf output
Hi all, After trying several ways around this problem, I've found a solution that is pretty straightforward and produces nice results. The problem I'm referring to is that when I saved my figures as encapsulated PostScript for inclusion in a LaTeX document, the figures came out missing certain text when the document is converted to pdf (e.g. using dvipdf on the dvi file or ps2pdf on the ps file created using dvips). One solution is to set the rcParams['text.usetex'] = True, but that leads to a different font (serif) used for the numbers and for the axis labels (there are ways around that also...) But the best way that I've found is to save the figures as pdf and then convert them to eps by using pdftops with the -eps flag. You do lose transparency that way, but the figure, including text, looks good. You can also use the convert command from the ImageMagick package to do the pdf to eps conversion, which maintains the transparency at the cost of a worse looking figure (bitmapped) overall. It'd be nice to know exactly why this problem occurs in the first place. I assume it has to do with the interaction of pdf with some fonts used in mathtext. Jon -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] mathtext in eps figures doesn't come out in pdf
I did have success converting my ps file to pdf with an online converter at http://www.ps2pdf.com/ -- so it seems it's ghostscript 8.70 bug (though one that I've only seen with eps files created by matplotlib). Jon On Fri, 2011-08-19 at 11:48 +0900, Jae-Joon Lee wrote: > When I converted the ps file to pdf, the result is okay. > > I tried > > * ps2pdf (from ghostscript version 8.61) > * ps2pdf (from ghostscript version 9.02) > * preview in mac os X > > and they all worked fine. > I wonder if this could be a bug in the pspdf (ghostscript 8.70 I believe). > Can you try other version of ps2pdf? > > Regards, > > -JJ > > > > On Wed, Aug 17, 2011 at 9:53 PM, Jonathan Slavin > wrote: > > Attached are examples of the problem -- a PostScript file and the pdf > > that is created using ps2pdf. The y-axis is properly labeled in the ps > > file, but the part of the label using mathtext becomes invisible in the > > pdf. > > > > Jon > > > > On Wed, 2011-08-17 at 14:09 +0900, Jae-Joon Lee wrote: > >> Can you post an output eps file so that we can take a look? > >> Regards, > >> > >> -JJ > >> > >> > >> > >> On Wed, Aug 17, 2011 at 5:52 AM, Jonathan Slavin > >> wrote: > >> > Hi all, > >> > > >> > I've been making figures for a paper I'm writing (to be submitted to the > >> > ApJ). I'm using LaTeX and so need to use encapsulated PostScript for > >> > the figures. The problem is that when the paper is translated to pdf > >> > from PostScript, the mathtext in the figures disappears. The reason > >> > that I think this is a matplotlib issue is that it's never happened to > >> > me with eps figures created in different ways. It's clear that this > >> > must be related to fonts, but I'm not sure how to get around it. Should > >> > I set text.usetex to True? I have a feeling this issue must have come > >> > up before, but I haven't found anything obviously pertinent in the > >> > mailing list archives. > >> > > >> > Jon > >> > > >> > > >> > -- > >> > Get a FREE DOWNLOAD! and learn more about uberSVN rich system, > >> > user administration capabilities and model configuration. Take > >> > the hassle out of deploying and managing Subversion and the > >> > tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 > >> > ___ > >> > Matplotlib-users mailing list > >> > [email protected] > >> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >> > > > -- > > __ > > Jonathan D. Slavin Harvard-Smithsonian CfA > > [email protected] 60 Garden Street, MS 83 > > phone: (617) 496-7981 Cambridge, MA 02138-1516 > > cell: (781) 363-0035 USA > > __ > > -- __ Jonathan D. Slavin Harvard-Smithsonian CfA [email protected] 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] problem with contour labels with logarithmic axis
Answering my own question... It's a question of order. I needed to
set_yscale('log') before calling clabel.
Jon
> Hi all,
>
> I've run into a problem with a contour plot that has a
> logarithmic
> y-axis. The spacing around the inline contour label is too
> large,
> leading to a large segment of the contour being blocked
> out/erased. I
> tried making the plot with a linear axis and it didn't happen
> in that
> case, so I'm thinking that it has to do with the contour
> labeling
> routine not understanding logarithmic scaling. Attached is a
> plot
> demonstrating the problem. Is there a solution for this?
>
> Jon Slavin
--
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the
BlackBerry® mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry® DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] cross hatching in contours?
I'm wondering if there is some way to do cross hatching as a way to fill contours rather than colors (using contourf). The only references to cross hatching I see in the documentation are for patches type objects. As far as I can tell, contour and contourf return objects of their own type (contour.QuadContourSet) that do not have hatch as an attribute. If it's not possible currently, how hard would it be to add that capability to contourf? What approach would you recommend? Regards, Jon -- Doing More with Less: The Next Generation Virtual Desktop What are the key obstacles that have prevented many mid-market businesses from deploying virtual desktops? How do next-generation virtual desktops provide companies an easier-to-deploy, easier-to-manage and more affordable virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/ ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
