I'm using IPython notebooks to save my results and perhaps to share code including graphics. I am using ggplot right now. But I cannot get ggplot to plot inside the notebook output area. It always gives me a pop-up window that shows the plot. I don't know how to save it along with the notebook easily. Is there something I need to configure to make that happen? "%matplotlib inline" I saw in a ggplot tutorial that below code should do it. What am I missing?
My code:
plot = ggplot(my_dataframe, aes("x")) + geom_histogram()
print plot
I got my answer elsewhere. It worked like a charm!
%pylab inline
Related
I am using Jupyter notebook and I'm trying to plot graphs using subplots based on this video:
I just tried everything in the same format as shown in the video.
When I do a simple plot,
For example,
plt.plot([1,2,3],[2,4,6])
It gives a normal result.
But, when I try to create two axis, like this,
ax1.plot(df.index, df['APT.AX'])
ax2.plot(df.index, df['A2M.AX'])
It just gives the following result:
Out: [<matplotlib.lines.Line2D at 0x1ab0e0db8b0>]
And when I enter plt.show(), it just does nothing.
I tried uninstalling and reinstalling matplotlib using conda. I have tried by adding %matplotlib inline before using it.
Anything I can do here?
That's not an error. Use show() in the next line or plt.show()
when I use
%matplotlib notebook
import matplotlib.pyplot as plt
I get interactive plots, i.e. I can also zoom into the figure.
For julia this command does not seem to exist. Any ideas?
You can get interactive plots by using Plotly, either directly with Plotly.jl or through its Plots backend.
Today I am thinking about how to enlarge the plot window interactively without referring to python or plotly or something else in Jupiter notebook. And I find a good solution. It is to use the package Interact. A simple example is as follows. You can get an interactive plot in 3 lines.
import Pkg; Pkg.add("Interact")
using LinearAlgebra, Plots, Interact
#manipulate for n in 10:100, w in 200:1000, h in 200:1000
plot(randn(n),randn(n),seriestype=:scatter,label="n=$(n)",size = (w, h))
end
The result looks like this
Trying to build seaborn FacetGrid plots in a Jupyter notebook. Upon creation, it displays just fine. But if I manipulate the chart and want to see it again, I cannot. I can only get the object listing.
How can I show the chart a second time?
You need to state the figure in a new cell to let it be displayed with the inline backend.
g.fig
g.fig doesn't work.Instead, g.figure works out.
I am currently trying to graph data using Python3 and matplotlib. I am developing on OSx Sierra and when I run, it is not showing up. There are no errors returned. I included plt.show() in my code and it is definitely running. Any help to get this graph showing would be appreciated. Vanilla Python3, edited in Emacs, ran from both IDLE and terminal. Neither work. Thank you.
import matplotlib.pyplot as plt
plt.show()
Does not produce anything, and there are no errors. I have tried
plt.switch_backend('MacOSX') and the error persists.
Just to wrap up the comments into an answer: pyplot.show() only produces a figure, if a figure has been created. This can be done explicitly by stating
fig = plt.figure()
or implicitly by plotting something (the figure is then created in the background), e.g.
plt.plot([1,2,3])
once plt.show() is called, all currently active figures will be displayed on the screen.
I have a long Jupyter notebook code and there is many cells, which are redrawing the actual graph plot. When I am running cells after changing their contents I need to check the plot, but I always need to scroll up and down. I would prefer to watch the plot changes in separated window (I am using two monitors), so I will change the cell content, run the cell, and then just turn my head and see the plot - without any scrolling. Is there a way how to do that? I know it can be done by Spyder, but I want to do it in Jupyter notebook, since I use a lot of notebook advantages, such as Latex notes and headings between cells. Thanks a lot for any advice!
It would be great if you could tell us how you print your graph (what library ?). Ipython provide magic command. For example, if you use matplotlib to plot some figures, just add %matplotlib qt on top of your cell to make the plots appear in a separate window.
See the list of magic command available here.