@@ -58,12 +58,19 @@ def _get_plot_data(data, ndim=None):
5858def _auto_params (data , c , discrete , cmap , legend ):
5959 """Automatically select nice parameters for a scatter plot
6060 """
61+ for d in data [1 :]:
62+ if d .shape [0 ] != data [0 ].shape [0 ]:
63+ raise ValueError ("Expected all axis of data to have the same length"
64+ ". Got {}" .format ([d .shape [0 ] for d in data ]))
6165 if c is not None and not mpl .colors .is_color_like (c ):
6266 try :
6367 c = c .values
6468 except AttributeError :
6569 # not a pandas Series
6670 pass
71+ if not len (c ) == data [0 ].shape [0 ]:
72+ raise ValueError ("Expected c of length {} or 1. Got {}" .format (
73+ len (c ), data .shape [0 ]))
6774 if discrete is None :
6875 # guess
6976 if isinstance (cmap , dict ) or \
@@ -124,7 +131,7 @@ def scatter(data,
124131 xlabel = "PHATE1" ,
125132 ylabel = "PHATE2" ,
126133 zlabel = "PHATE3" ,
127- legend_title = None ,
134+ legend_title = "" ,
128135 ** plot_kwargs ):
129136 """Create a scatter plot
130137
@@ -184,7 +191,7 @@ def scatter(data,
184191 Label for the y axis. If None, no label is set.
185192 zlabel : str or None (default : "PHATE3")
186193 Label for the z axis. If None, no label is set. Only used for 3D plots
187- legend_title : str or None (default: None )
194+ legend_title : str (default: "" )
188195 title for the colorbar of legend
189196 **plot_kwargs : keyword arguments
190197 Extra arguments passed to `matplotlib.pyplot.scatter`.
@@ -208,10 +215,12 @@ def scatter(data,
208215 else :
209216 show = False
210217 if legend and not discrete :
211- im = ax .imshow (np .arange ( 10 ).reshape (- 1 , 1 ),
218+ im = ax .imshow (np .linspace ( np . min ( data [ 1 ]), np . max ( data [ 1 ]), 10 ).reshape (- 1 , 1 ),
212219 vmin = np .min (c ), vmax = np .max (c ), cmap = cmap ,
213- aspect = 'auto' )
220+ aspect = 'auto' , origin = 'lower' )
214221 im .remove ()
222+ ax .relim ()
223+ ax .autoscale ()
215224 try :
216225 if c is not None and not mpl .colors .is_color_like (c ):
217226 c = c [plot_idx ]
0 commit comments