-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Scatterplot Update for #3473 #4930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1193,7 +1193,29 @@ def _post_plot_logic(self): | |
for ax in self.axes: | ||
ax.legend(loc='best') | ||
|
||
|
||
class ScatterPlot(MPLPlot): | ||
def __init__(self, data, **kwargs): | ||
MPLPlot.__init__(self, data, **kwargs) | ||
if 'x' not in kwargs and 'y' not in kwargs: | ||
raise ValueError( 'Scatterplot requires and X and Y column') | ||
|
||
def _make_plot(self): | ||
plotf = self._get_plot_function() | ||
colors = self._get_colors() | ||
|
||
for i, (label, y) in enumerate(self._iter_data()): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same deal. 'y' is the column where y values come from. Then you iterate through the rows and use 'y' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you're misunderstanding how name binding works. See my second comment below. |
||
ax = self._get_ax(i) | ||
#kwds = self.kwds.copy() | ||
x, y = self.kwds['x'], self.kwds['y'] | ||
#print x, y | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these two |
||
ax = ax.scatter(x, y) | ||
style = self._get_style(i, label) | ||
|
||
def _post_plot_logic(self): | ||
if self.subplots and self.legend: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So you only want a legend to be shown if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure about this. I used the line or barplot class as template. I'm not really familiar with subplotting |
||
for ax in self.axes: | ||
ax.legend(loc='best') | ||
|
||
class LinePlot(MPLPlot): | ||
|
||
def __init__(self, data, **kwargs): | ||
|
@@ -1554,7 +1576,7 @@ def plot_frame(frame=None, x=None, y=None, subplots=False, sharex=True, | |
secondary_y=False, **kwds): | ||
|
||
""" | ||
Make line or bar plot of DataFrame's series with the index on the x-axis | ||
Make line, bar, or scater plots of DataFrame series with the index on the x-axis | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: scater -> scatter |
||
using matplotlib / pylab. | ||
|
||
Parameters | ||
|
@@ -1585,10 +1607,11 @@ def plot_frame(frame=None, x=None, y=None, subplots=False, sharex=True, | |
ax : matplotlib axis object, default None | ||
style : list or dict | ||
matplotlib line style per column | ||
kind : {'line', 'bar', 'barh', 'kde', 'density'} | ||
kind : {'line', 'bar', 'barh', 'kde', 'density', 'scatter'} | ||
bar : vertical bar plot | ||
barh : horizontal bar plot | ||
kde/density : Kernel Density Estimation plot | ||
scatter: scatter plot | ||
logx : boolean, default False | ||
For line plots, use log scaling on x axis | ||
logy : boolean, default False | ||
|
@@ -1624,6 +1647,8 @@ def plot_frame(frame=None, x=None, y=None, subplots=False, sharex=True, | |
klass = BarPlot | ||
elif kind == 'kde': | ||
klass = KdePlot | ||
elif kind == 'scatter': | ||
klass = ScatterPlot | ||
else: | ||
raise ValueError('Invalid chart type given %s' % kind) | ||
|
||
|
@@ -1639,21 +1664,35 @@ def plot_frame(frame=None, x=None, y=None, subplots=False, sharex=True, | |
label = kwds.pop('label', label) | ||
ser = frame[y] | ||
ser.index.name = label | ||
return plot_series(ser, label=label, kind=kind, | ||
use_index=use_index, | ||
rot=rot, xticks=xticks, yticks=yticks, | ||
xlim=xlim, ylim=ylim, ax=ax, style=style, | ||
grid=grid, logx=logx, logy=logy, | ||
secondary_y=secondary_y, title=title, | ||
figsize=figsize, fontsize=fontsize, **kwds) | ||
|
||
plot_obj = klass(frame, kind=kind, subplots=subplots, rot=rot, | ||
legend=legend, ax=ax, style=style, fontsize=fontsize, | ||
use_index=use_index, sharex=sharex, sharey=sharey, | ||
xticks=xticks, yticks=yticks, xlim=xlim, ylim=ylim, | ||
title=title, grid=grid, figsize=figsize, logx=logx, | ||
logy=logy, sort_columns=sort_columns, | ||
secondary_y=secondary_y, **kwds) | ||
if kind != 'scatter': | ||
return plot_series(ser, label=label, kind=kind, | ||
use_index=use_index, | ||
rot=rot, xticks=xticks, yticks=yticks, | ||
xlim=xlim, ylim=ylim, ax=ax, style=style, | ||
grid=grid, logx=logx, logy=logy, | ||
secondary_y=secondary_y, title=title, | ||
figsize=figsize, fontsize=fontsize, **kwds) | ||
if kind == 'scatter': | ||
plot_obj = klass(frame, x=frame.index, y=ser, | ||
kind=kind, subplots=subplots, rot=rot, | ||
legend=legend, ax=ax, style=style, fontsize=fontsize, | ||
use_index=use_index, sharex=sharex, sharey=sharey, | ||
xticks=xticks, yticks=yticks, xlim=xlim, ylim=ylim, | ||
title=title, grid=grid, figsize=figsize, logx=logx, | ||
logy=logy, sort_columns=sort_columns, | ||
secondary_y=secondary_y, **kwds) | ||
|
||
else: | ||
plot_obj = klass(frame, kind=kind, subplots=subplots, rot=rot, | ||
legend=legend, ax=ax, style=style, fontsize=fontsize, | ||
use_index=use_index, sharex=sharex, sharey=sharey, | ||
xticks=xticks, yticks=yticks, xlim=xlim, ylim=ylim, | ||
title=title, grid=grid, figsize=figsize, logx=logx, | ||
logy=logy, sort_columns=sort_columns, | ||
secondary_y=secondary_y, **kwds) | ||
|
||
|
||
|
||
plot_obj.generate() | ||
plot_obj.draw() | ||
if subplots: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should have been removed?