Re: [Matplotlib-users] Incomplete rendering of line plot
Tom Aldcroft wrote: > I've run into a case where the rendering in a line plot is incomplete > and some lines are not drawn at all. Basically I have a dataset (see > below) where I know two points go to a value of zero. When I plot > the points and do interactive pan/zoom sometimes the line going down > to zero is there and sometimes not. After a bunch of playing around > trying to reduce the problem to a minimum the script below is what I > got. If I tried to make the 'y' array much smaller then the problem > went away. I played with antialias and interactive settings with no > benefit. Changing the window size can also produce the same effect > I'm describing. Finally, when I use savefig to save in various > formats the results varied, perhaps just a side-effect of the size of > the saved figure. > > I'm using Matplotlib 0.99.1.1 built from source with the TkAgg backend > on CentOS-5 with python 2.6. This same problem was also evident using > GtkAgg and MacOSX backends so I don't think the details of my build > are relevant (but I can supply if needed). > > Thanks, Tom It works for me in svn, so I am pretty sure you have run into the infamous path simplification bug. If you are building from source anyway, then just build from svn. Alternatively, you can put path.simplify : False in your matplotlibrc file to disable path simplification. Eric > > import numpy > import matplotlib.pyplot as plt > > y = numpy.array([ > 4., 2., 2., 3., 3., 2., 2., 6., 6., 5., 5., 4., 4., > 7., 7., 2., 2., 4., 4., 2., 2., 2., 2., 4., 4., 4., > 4., 4., 4., 7., 7., 3., 3., 5., 5., 4., 4., 5., 5., > 4., 4., 7., 7., 6., 6., 2., 2., 2., 2., 5., 5., 4., > 4., 4., 4., 6., 6., 3., 3., 4., 4., 3., 3., 2., 2., > 3., 3., 4., 4., 4., 4., 4., 4., 6., 6., 5., 5., 4., > 4., 7., 7., 3., 3., 4., 4., 4., 4., 5., 5., 4., 4., > 7., 7., 3., 3., 4., 4., 4., 4., 6., 6., 4., 4., 4., > 4., 4., 4., 2., 2., 5., 5., 6., 6., 3., 3., 5., 5., > 4., 4., 0., 0., 5., 5., 1., 1., 4., 4., 5., 5., 4.]) > > plt.figure() > plt.plot(y) > > plt.figure() > plt.plot(y) > plt.xlim(-7200, 6500) > # Does it go down to 0 now? > > -- > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Incomplete rendering of line plot
I've run into a case where the rendering in a line plot is incomplete and some lines are not drawn at all. Basically I have a dataset (see below) where I know two points go to a value of zero. When I plot the points and do interactive pan/zoom sometimes the line going down to zero is there and sometimes not. After a bunch of playing around trying to reduce the problem to a minimum the script below is what I got. If I tried to make the 'y' array much smaller then the problem went away. I played with antialias and interactive settings with no benefit. Changing the window size can also produce the same effect I'm describing. Finally, when I use savefig to save in various formats the results varied, perhaps just a side-effect of the size of the saved figure. I'm using Matplotlib 0.99.1.1 built from source with the TkAgg backend on CentOS-5 with python 2.6. This same problem was also evident using GtkAgg and MacOSX backends so I don't think the details of my build are relevant (but I can supply if needed). Thanks, Tom import numpy import matplotlib.pyplot as plt y = numpy.array([ 4., 2., 2., 3., 3., 2., 2., 6., 6., 5., 5., 4., 4., 7., 7., 2., 2., 4., 4., 2., 2., 2., 2., 4., 4., 4., 4., 4., 4., 7., 7., 3., 3., 5., 5., 4., 4., 5., 5., 4., 4., 7., 7., 6., 6., 2., 2., 2., 2., 5., 5., 4., 4., 4., 4., 6., 6., 3., 3., 4., 4., 3., 3., 2., 2., 3., 3., 4., 4., 4., 4., 4., 4., 6., 6., 5., 5., 4., 4., 7., 7., 3., 3., 4., 4., 4., 4., 5., 5., 4., 4., 7., 7., 3., 3., 4., 4., 4., 4., 6., 6., 4., 4., 4., 4., 4., 4., 2., 2., 5., 5., 6., 6., 3., 3., 5., 5., 4., 4., 0., 0., 5., 5., 1., 1., 4., 4., 5., 5., 4.]) plt.figure() plt.plot(y) plt.figure() plt.plot(y) plt.xlim(-7200, 6500) # Does it go down to 0 now? -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] smoother plots - pcolormesh
imshow has a number of different interpolation methods you can try: http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.imshow Mike John wrote: > Hello, > > I'm trying to plot 0.5x0.5 global data. I'm currently using > pcolormesh. I have a log color scale and haven't been able to use > contourf succesfully for some reason. If I use imshow, it seems to be > too 'bleedy'. > > Is there a method for plotting that does some more 'smoothing' > interpolation of the data than pcolormesh? Is there something I'm > doing wrong that contourf doesn't work with log data? > > Thanks, > john > > -- > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] legend: symbols is duplicated
Many thanks! carlos On Thu, Apr 22, 2010 at 18:54, Gökhan Sever wrote: > > > On Thu, Apr 22, 2010 at 4:44 PM, Carlos Grohmann > wrote: >> >> Hi all, >> >> I'm getting this weird behavior of legend. I always get two symbols in >> front of the labels, instead of one. >> Did anyone experienced this before? >> >> I'm working with MPL in a WxPython app. >> >> code snippet: >> >> >> [code] >> for i in range(len(self.idxPlan)): >> x = self.PeigenList[i][14] + (self.PeigenList[i][15] / 2) >> y = self.PeigenList[i][15] * sqrt3_2 >> axes.plot(x,y, self.PProps[i][3], c=self.PProps[i][2], >> ms=self.PProps[i][4],label=self.Pname[i]) >> >> axes.legend(bbox_to_anchor=(0.85, 0.75), loc=2, >> prop=FontProperties(size='small')) >> >> axes.set_xlim(-0.1,1.2) >> axes.set_ylim(-0.1,1.2) >> self.dataCanvas.draw() >> >> [\code] >> >> >> tks >> -- >> Prof. Carlos Henrique Grohmann - Geologist D.Sc. >> Institute of Geosciences - Univ. of São Paulo, Brazil >> http://www.igc.usp.br/pessoais/guano >> Linux User #89721 >> >> Can’t stop the signal. > > Hi, > > Try using numpoints keyword: > > plt.legend(numpoints=1) > > > -- > Gökhan > -- Prof. Carlos Henrique Grohmann - Geologist D.Sc. Institute of Geosciences - Univ. of São Paulo, Brazil http://www.igc.usp.br/pessoais/guano Linux User #89721 Can’t stop the signal. -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Issues with Circle
Hi, I'm having issues with translucent patches. The following code import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as mpl from matplotlib.patches import Circle fig = mpl.figure() ax = fig.add_subplot(111) c = Circle((0.25,0.5), radius=0.2, facecolor='none', edgecolor='green', alpha=0.2) ax.add_patch(c) c = Circle((0.75,0.5), radius=0.2, facecolor='blue', edgecolor='green', alpha=0.2) ax.add_patch(c) fig.savefig('test_alpha.png') Produces a plot where the two circles have different borders - the left circle has a border with alpha=1.0 and the right circle has a border with alpha=0.2. Should I submit this as a bug report? I am also having issues with the following script: import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as mpl from matplotlib.patches import Circle import time fig = mpl.figure() ax = fig.add_subplot(111) ax.add_patch(Circle((1.e10,1.e10), radius=1.e9)) time1 = time.time() fig.savefig('test_perf.png') print "Time to save: %.3f" % (time.time() - time1) The issue is that the time to save is typically 3 seconds or so, up to 5 seconds in some caes (way more than normal), and the axes do not autoscale to show the patch (I imagine the two issues are related). Is this a bug, or just due to the way matplotlib works? Thanks for any help, Thomas -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Can't turn-off ticks when sharing axis
On Thu, Apr 22, 2010 at 7:38 PM, John Hunter wrote: > > The standard trick is to make the ticklabels on one axes invisible > > for label in ax.get_xticklabels(): >label.set_visible(False) > > > JDH > Thanks John, This answer seems familiar to me :) You have caught my intention correctly --not completely clearing the x-axis but rather turning-off the labels. Your trick works independent from sharing state of an x-axis. Alternatively, I use ax.xaxis.set_ticklabels ("") to clear tick-labels when I don't share the axis. -- Gökhan -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] patch: adding kwargs 'which' in axes.grid and 'g' toggles all tick grid lines
Hello list, Hello developers, I'd like to summarize my discussion with Gökhan ("Turning off minor grids on log scaled plot") in the last days and propose two patches. The first patch adds the keyword argument 'which' from the axis.grid to the method 'grid' of the Axes (axes_grid_for_major_and_minor_ticks.patch). This allows to change the drawing of grid lines for x- and y-axis at the same time. Furthemore Gökhan proposed to toggle *all* (namely major and minor tick) grid lines after pressing the key 'g'. Therefore the call event.inaxes.grid(), which toggles only the (default) major tick grid lines, is replaced by event.inaxes.grid(which='majorminor') (see toggling_all_tick_grid_lines.patch). This yields the expected behavior if e.g. all (major and minor) tick grid lines are shown, because than toggling the grid means to remove all grid lines. But to be honest I'm not sure the latter is the intended behavior in all cases. For instance in the case of shown major tick lines toggling all means turning off major tick lines and turning on minor tick lines by pressing 'g'. This sounds a little bit crazy to me, although that's what toggling is about. Thanks in advance for any comments. Kind regards, Matthias Index: lib/matplotlib/axes.py === --- lib/matplotlib/axes.py (revision 8267) +++ lib/matplotlib/axes.py (working copy) @@ -1932,19 +1932,20 @@ self._axisbelow = b @docstring.dedent_interpd -def grid(self, b=None, **kwargs): +def grid(self, b=None, which='major', **kwargs): """ call signature:: - grid(self, b=None, **kwargs) + grid(self, b=None, which='major', **kwargs) -Set the axes grids on or off; *b* is a boolean +Set the axes grids on or off; *b* is a boolean. Use *which* = +'major' | 'minor' to set the grid for major or minor ticks. If *b* is *None* and ``len(kwargs)==0``, toggle the grid state. If *kwargs* are supplied, it is assumed that you want a grid and *b* is thus set to *True* -*kawrgs* are used to set the grid line properties, eg:: +*kwargs* are used to set the grid line properties, eg:: ax.grid(color='r', linestyle='-', linewidth=2) @@ -1953,8 +1954,8 @@ %(Line2D)s """ if len(kwargs): b = True -self.xaxis.grid(b, **kwargs) -self.yaxis.grid(b, **kwargs) +self.xaxis.grid(b, which=which, **kwargs) +self.yaxis.grid(b, which=which, **kwargs) def ticklabel_format(self, **kwargs): """ Index: lib/matplotlib/backend_bases.py === --- lib/matplotlib/backend_bases.py (revision 8267) +++ lib/matplotlib/backend_bases.py (working copy) @@ -2109,9 +2109,9 @@ # the mouse has to be over an axes to trigger these # switching on/off a grid in current axes (default key 'g') if event.key in grid_keys: -event.inaxes.grid() +event.inaxes.grid(which="majorminor") self.canvas.draw() -# toggle scaling of y-axes between 'log and 'linear' (default key 'l') +# toggle scaling of y-axes between 'log' and 'linear' (default key 'l') elif event.key in toggle_yscale_keys: ax = event.inaxes scale = ax.get_yscale() @@ -2121,7 +2121,7 @@ elif scale == 'linear': ax.set_yscale('log') ax.figure.canvas.draw() -# toggle scaling of x-axes between 'log and 'linear' (default key 'k') +# toggle scaling of x-axes between 'log' and 'linear' (default key 'k') elif event.key in toggle_xscale_keys: ax = event.inaxes scalex = ax.get_xscale() -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users