python - pandas scatterplots: how to plot data on a secondary y axis? -
i want put 2 scatterplots on same graph x axis shared y axes different. can't work out how there though. create first scatterplot doing:
ax=df.plot(kind='scatter', x='vf', y='hf_ratio', xlim=[2e-06,6e-06], ylim=[1,10], color='darkblue', s=40, label='a') ax.ticklabel_format(axis='x', style='sci', scilimits=(0,0))
now want add second on right-hand y axis. pandas documentation gives info adding secondary axis line plot (secondary_y=true
) i've tried doesn't seem work:
df.plot(kind='scatter', x='vf', y='hfall', secondary_y=true, color='red', s=40, label='hfall', ax=ax);
it seems ignore secondary_y=true
command , plots on original y axis, isn't useful. rub further salt wounds, removes attractive white gridlines...
if able appreciated.
this seems issue (bug?) pandas code. has been reported in github page here. explanation give there, happening secondary_y
keyword works line plots, , not scatter plots trying here.
the workaround suggested in link use line plot, changing style dots (not sure if enough needs). in case, like:
ax=df.plot(kind='line', x='vf', y='hf_ratio', xlim=[2e-06,6e-06], ylim=[1,10], color='darkblue', style='.', markersize=5, label='a') df.plot(kind='line', x='vf', y='hfall', secondary_y=true, color='red', style='.', markersize=5, label='hfall', ax=ax);
Comments
Post a Comment