On 2014/03/04 12:56 PM, Stuart Mentzer wrote:
> Hi,
>
> I'm seeing odd behavior with the relim() and autoscale_view() call
> sequence with matplotlib 1.3.1. In some cases I am ending up with axis
> ranges of [-0.05,0.05] instead of the actual data ranges. This happens
> with scatter plots and sometimes with contour plots.

Why are you trying to use relim() here?  It does not support 
collections, and scatter produces a collection.  It doesn't find any 
Artists that it knows about, so it assumes nothing has been added to the 
plot, and it yields a generic set of limits.

Eric

>
> The modified version of the scatter_demo2 below displays the problem. I
> think this used to work for scatter plots with earlier versions of
> matplotlib. Is this supposed to work or is there another way to do it
> correctly (other than doing our own limit setting)?
>
> Thanks,
> Stuart
>
> """
> Demo of scatter plot with varying marker colors and sizes.
> """
> import numpy as np
> import matplotlib.pyplot as plt
> import matplotlib.cbook as cbook
>
> # Load a numpy record array from yahoo csv data with fields date,
> # open, close, volume, adj_close from the mpl-data/example directory.
> # The record array stores python datetime.date as an object array in
> # the date column
> datafile = cbook.get_sample_data('goog.npy')
> price_data = np.load(datafile).view(np.recarray)
> price_data = price_data[-250:] # get the most recent 250 trading days
>
> delta1 = np.diff(price_data.adj_close)/price_data.adj_close[:-1]
>
> # Marker size in units of points^2
> volume = (15 * price_data.volume[:-2] / price_data.volume[0])**2
> close = 0.003 * price_data.close[:-2] / 0.003 * price_data.open[:-2]
>
> fig, ax = plt.subplots()
> ax.scatter(delta1[:-1], delta1[1:], c=close, s=volume, alpha=0.5)
>
> # These cause ranges to be set incorrectly to [-0.055,0.055] !!!!!!!!!!
> ax.relim()
> ax.autoscale_view( tight = True )
>
> ax.set_xlabel(r'$\Delta_i$', fontsize=20)
> ax.set_ylabel(r'$\Delta_{i+1}$', fontsize=20)
> ax.set_title('Volume and percent change')
>
> ax.grid(True)
>
> fig.tight_layout()
>
> plt.show()
>
>
> ------------------------------------------------------------------------------
> Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
> With Perforce, you get hassle-free workflows. Merge that actually works.
> Faster operations. Version large binaries.  Built-in WAN optimization and the
> freedom to use Git, Perforce or both. Make the move to Perforce.
> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>


------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works. 
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to