Reputation: 3433
The situation: I have a jupyter notebook where I create and manipulate a DataFrame.
At a certain point I have:
mydf = conceptsdf['date'].groupby([conceptsdf['date'].dt.year, conceptsdf['date'].dt.month]).agg('count')
mydf.plot(kind="bar")
basically I aggregate occurrences per month. The plot appears correctly as expected in the notebook under the line:
<matplotlib.axes._subplots.AxesSubplot at 0x283dc381148>
The Problem: I have voila installed and when I click it all works fine but in the voila web result the plot does not appear but only the line:
AxesSubplot(0.125,0.11;0.775x0.77)
Any ideas what to do to get the plots in voila output as well.
Upvotes: 0
Views: 1436
Reputation: 9810
With the limited code that you posted, I'd guess you aren't using %matplotlib widget
?
Example using pandas plot that works (see links below for demo notebook):
%matplotlib widget
import pandas as pd
iris = pd.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv')
iris.plot.hist();
As documented here and stated here as, "Under the hood, pandas plots graphs with the matplotlib library." And so that approach will work with matplotlib in general.
Example working matplotlib plot in a cell from my notebook (linked below):
%matplotlib widget
import matplotlib.pyplot
import matplotlib.pyplot as plt
import numpy as np
fig = matplotlib.pyplot.figure()
a = matplotlib.pyplot.imshow(np.random.randn(100, 100))
a.figure
I have some examples based on code I collected previously and this discussion here. For the Pandas dataframe plot, go to https://github.com/fomightez/communication_voila/ and click the badge next the text 'Start with the Pandas dataframe plot demo as a notebook'. After launch, you can run all the cells and then click the Voila
button in the toolbar at the top.
For the matplotlib examples page, go to https://github.com/fomightez/communication_voila/ and click the badge next the text 'Start with the matplotlib demo as a notebook'. After launch, you can run all the cells and then click the Voila
button in the toolbar at the top.
Those notebooks and the 'Examples' referenced here might provide a good basis for solving your issue.
Upvotes: 1