when I display the distributtion plot it works just fine and I get my graph displayed.
sns.distplot(df['Price'])
when I add a new code line to display the heatmap of the corr:
sns.heatmap(df.corr())
it Crushes my old graph and get displayed at its place.
can't get both graphs displayed at the same time.
You can try displaying multiple images in Jupyter notebooks with the IPython.display.display() method. IPython is the python shell used by Jupyter notebooks, so you can import it without installing any external libraries. Just wrap your plots inside the function like you would with a print method:
from IPython.display import display
display(sns.distplot(df['Price']))
display(sns.heatmap(df.corr()))
I am currently working in a project where i need to display Enthalpy/Pressure diagram which look like this:
Diagram enthalpy/Pressure
I am doing it with matplotlib & Coolprop using this kind of code:code diagram
I want an interactive figure where i can see the values of all the points i draw just by passing my mouse on them.
I know that plotly allow this kind of thing, so my question is how can i convert my matplotlib figure into a plotly one or how can i change my code to use plotly instead of matplotlib ?
Thank you
I am making some small tests in Jupyter. The user should see two plots, one on the left and one on the right. Than after clicking somewhere on the left plot something on the right plot should happen. For example here a click on the left plot will produce a red dot on the right plot in the same place:
%matplotlib notebook
def onclick(event):
ax.clear()
ax2.clear()
ax.set_xlim(0,10)
ax.set_ylim(0,10)
ax2.set_xlim(0,10)
ax2.set_ylim(0,10)
ax2.plot([event.xdata],[event.ydata],'o',color='red')
ax.figure.canvas.draw_idle()
ax2.figure.canvas.draw_idle()
fig = plt.figure(figsize=(20,10))
ax = fig.add_subplot(121)
ax2 = fig.add_subplot(122)
ax.set_xlim(0,10)
ax.set_ylim(0,10)
ax2.set_xlim(0,10)
ax2.set_ylim(0,10)
cid = fig.canvas.mpl_connect('button_press_event',onclick)
This works, but the visualization in Jupyter is not the best. Is there a way to have this kind of interactive plots working outside of a Jupyter notebook ? Maybe in a window with varying dimensions ? As an example, how would one proceed with the example above ?
You can use plotly and export your plots to html file:
https://plotly.com/python/interactive-html-export/
I think I found a possible simple answer to my needs. Simply put the code in the question in a python script, remove the 'magic' command and insert at the end:
plt.show(block=True)
This way matplotlib will just use a different backend than notebook or inline in Jupiter and plot the figure in a separate window. This window is compatible with the interactive commands from matplotlib. I am not sure about widget compatibility though I will try and update the answer.
Update: I do not think ipywidgets can be used with plt.show() since these are not plotted in an axes, but there are some widgets within matplotlib (matplotlib.widgets) that can be used. Though, the resulting speed in my case is not satisfactory so I would avoid combining matplotlib widgets with matplotlib event catching.
I'm trying to create an interactive Heatmap in Jupyter :
I want to be able to display a graph when double-clicking on the different cells. For instance when clicking on the cell corresponding to correlation between A and B I want to display a graph showing corr(A,B) across time.
It appears that neither plotly nor seaborn allows me to do that. Any help is well appreciated !
I am facing the following problem: I need two interactive plots to work at the same time on Jupyter, however they are interfering. When I rotate the cell of the first, the second plot stops being interactive and becomes "inline". Other times one of the plots looks like this:
The expected result was something like this
I imagine the problem is in the implementation I made. As you can see below, I use plt.something to put things in the figure (both for plot 1 and plot 2).
I'm using the %matplotlib notebook environment and tried to implement using fig1, ax1 = plt.subplots(). I would like to know if it is possible to do this type of implementation, where there is no conflict between plots? Maybe I am using matplotlib badly, so I would like some suggestions.