Skip to content
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

Generalize the figure= keyword argument to all kind of plot #122

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

Sigmun
Copy link

@Sigmun Sigmun commented Jan 6, 2022

No description provided.

@Sigmun
Copy link
Author

Sigmun commented Jan 6, 2022

Should solve #86

@PatrikHlobil
Copy link
Owner

Hi @Sigmun, thanks for contributing. I will try to have a detailled look at the MR as soon as possible, I am quite busy now.

I already tried to implement this feature, but struggled how the API should be designed. There are a few critical issues that have to be settled:

  1. Should we check the plotting type (line, bar, ...) and only allow certain combinations that make sense
  2. How should we handle the case when the first plot has a different numerical range as the second (x/y range, ticks, etc)
  3. Errorhandling in the code or indirect via Bokeh API

What do you think about that?

Best Patrik

@kkimdev
Copy link

kkimdev commented Jan 12, 2022

Thanks for working on this! I just wanted to note that this is the default behavior of matplotlib backend, and has been very productive for me. We don't have to copy exactly, but maybe we can reference what matplotlib is doing in some aspects.

Regarding 1 & 2 : One option I think it makes is respecting the first plot.

fig = s1.plot(kind='line', show_figure=False)  #first
s2.plot(kind="bar", figure=fig)                #second

The first line is responsible for "creating" a figure, and second line is "using" an already created plot so I think such behavior is intuitive API wise as well.

@rraymondgh
Copy link

this looks like a very good change to me. without it the higher level API that pandas-bokeh offers removes a significant number of use cases. As well as working with matplotlib and plotly that offer this capability have also worked with geopandas explore()which provides similar type API to folium. effectively building up a figure from a sequence of layers

@PatrikHlobil
Copy link
Owner

@rraymondgh: As already mentioned I wanted this feature for nearly 1,5 years, but couldn't find the time to implement it. The problems are outlined above and the current code status is a bit messy, so in order to implement the feature, I would have to refactor the code quite a lot.

@algomaschine
Copy link

Gents, I'm sorry, still having issues figuring out how to plot 2 lines of different style in HTML.

Let's say here's an example. df would have different columns. I want to display one of it as normal line, but some others as discrete arrows (to show my signals) or circles or whatever, to mark the main line with some entries/exists. Also how can I make solid vertical line for xticks? They're kind of very pale. Thanks!

with open("osc_multimodel_forecast_plot.html" , "w") as f: html = df.plot_bokeh(kind='line', title="BB S&P", xticks=xticks, vertical_xlabel=True,figsize=(2000, 1000), show_figure=True,return_html=True, xlabel='date', ylabel='Price', hovertool=True, zooming=True,panning=True, legend='top_right') f.write(html+"\n") f.close()

@Sigmun
Copy link
Author

Sigmun commented Feb 1, 2023

Gents, I'm sorry, still having issues figuring out how to plot 2 lines of different style in HTML.

Let's say here's an example. df would have different columns. I want to display one of it as normal line, but some others as discrete arrows (to show my signals) or circles or whatever, to mark the main line with some entries/exists. Also how can I make solid vertical line for xticks? They're kind of very pale. Thanks!

with open("osc_multimodel_forecast_plot.html" , "w") as f: html = df.plot_bokeh(kind='line', title="BB S&P", xticks=xticks, vertical_xlabel=True,figsize=(2000, 1000), show_figure=True,return_html=True, xlabel='date', ylabel='Price', hovertool=True, zooming=True,panning=True, legend='top_right') f.write(html+"\n") f.close()

Hi @algomaschine, I don't see the link with this PR. you need to open an issue for your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants