So it turns out when you want to use interactive plots (i.e. with zooming, moving around, rotating etc.) in jupyter lab with a python kernel, you need to use %matplotlib widget, this at least works for me. Now the question is: How could I use that feature with a julia kernel? I am a big fan of both matplotlib and julia and I do not want to compromise on them. When I type the above command with a julia kernel, I get the message
The analogue of IPython's %matplotlib in Julia is to use the PyPlot package, which gives a Julia interface to Matplotlib including inline plots in IJulia notebooks. (The equivalent of numpy is already loaded by default in Julia.) Given PyPlot, the analogue of %matplotlib inline is using PyPlot, since PyPlot defaults to inline plots in IJulia. To enable separate GUI windows in PyPlot, analogous to %matplotlib, do using PyPlot; pygui(true). To specify a particular gui backend, analogous to %matplotlib gui, you can either do using PyPlot; pygui(:gui); using PyPlot; pygui(true) (where gui is wx, qt, tk, or gtk), or you can do ENV["MPLBACKEND"]=backend; using PyPlot; pygui(true) (where backend is the name of a Matplotlib backend, like tkagg).
For more options, see the PyPlot documentation.
This of course is all true, but it does not mention how interactivity could be achieved. PyPlot works out of the box, but the plots are non-interactive (in the above sense). Any ideas?
See the PyPlot docs here: https://github.com/JuliaPy/PyPlot.jl for details on setting up interactive plots and such.
This gist may also be of use to you: https://gist.github.com/gizmaa/7214002. I would also suggest looking into Makie.jl for more rich interactive plotting.
Edit:
This question may also be relevant to you: Inline Interactive Plots with Julia in jupyter notebook
Related
I am making interactive worksheets in Jupyter Notebook, introducing people to NetworkX. Suddenly, the nx.draw() command is not creating an output of a graph. It was working fine before, and I haven't changed anything about the code I was using. For example, one block of code that was working fine before was:
import networkx as nx
G2 = nx.Graph()
G2.add_nodes_from([1,2,3,4,5,6,7])
edgelist = [(1,4),(1,6),(1,7),(2,5),(2,6),(3,7),(4,6),(4,7),(5,7),(6,7)]
G2.add_edges_from(edgelist)
nx.draw_networkx(G2, with_labels=True, node_color = 'y')
Now, no errors come up, but neither does a graph. I have looked and seen that other people fixed this issue bu using plt.show() but I don't understand why I suddenly need to include that when I didn't have to before. Does anyone know a way I can avoid importing matplotlib and using the plt.show() command?
Perhaps the issue is to do with some other package I have or something to do with jupyter notebook?
EDIT: It has been pointed out to me that matplotlib is a package dependency so technically there is no way of drawing a graph in networkx without using matplotlib. I understand that, but is there a way to do it without explicitly calling matplotlib?
I know spectrogram can be plotted using different functions of the different libraries in python. In matplotlib, plyplot plots spectrogram directly using time-series audio data but librosa first applies short Fourier transform on data before plotting spectrogram.
But I am still confused between two.
Please tell me the detailed difference between
1.librosa.dispay.specshow()
2.matplotlib.pyplot.specgram()
I have searched the internet a lot but couldn't find any relevant information though.
According to librosa documentation, all librosa plotting functions are depends on matplotlib.
All of librosa’s plotting functions rely on matplotlib. To demonstrate everything we can do, it will help to import matplotlib’s pyplot API here.
Encountered this issue with 2 different visualization libraries.
PYLDAVIS and DISPLACY (spacy).
On executing a code in jupyterlab (kernel as python3), the output expected should be Jupyter Notebook to show the graph or webcontent. But my Jupyter doesnt show any output with graph / dependency image . I only see textual output in JupyterLab.
eg.
displacy.serve(doc, style='dep')
I'm using KAGGLE docker image which has JUPYTERLAB and on top of that I have updated to latest packages.
Any pointers if this is JUPYTERLAB related or underlying packages?
I can only really comment on the spaCy part of this, but one thing I noticed is that you are using displacy.serve instead of displacy.render, which would be the correct method to call from within a Jupyter environment (see the spaCy visualizer docs for a full example and more details). The reason behind this is that displacy.serve will start a web server to show the visualization in a browser – all of which is not necessary if you're already in a Jupyter Notebook. So when you call displacy.render, it will detect your Jupyter environment, and wrap the visualization accordingly. You can also set jupyter=True to force this behaviour.
try
from spacy import displacy
displacy.render(doc, style="dep", jupyter=True, options={'distance': 140})
or
displacy.render(doc, style="ent", jupyter=True, options={'distance': 140})
I have recently upgraded my SciPy stack. Ipython Notebooks that previously worked now fail in the new Jupyter Notebook.
Previously I could evaluate SymPy matrices using SciPy/NumPy functions. Below is a minimal example with the eig function from SciPy performed on a SymPy matrix. It returns object arrays are not supported. This did not used to happen. During my upgrade several packages may have upgraded, including SymPy.
I don't know how it worked in your previous setup, but the process of converting SymPy matrices to NumPy arrays was explicit as early as 2012, per this answer, and SymPy has a utility function matrix2numpy for this purpose. So, in your context
LA.eig(matrix2numpy(M, dtype=float))
returns the expected eigenvalues. Without the helper function, it could be
LA.eig(np.array(M.tolist(), dtype=float))
If you'd like SciPy functions to accept SymPy objects, that would be an issue for their tracker, rather than a question for Stack Overflow.
I have a lot of data that comes from some experiment, just one column "measure" and would like to calculate ROC/AUC curves. I use matplotlib and had a look, but found no way to do with it. I wonder if anyone can share experiences with matplotlib or with any other open source easy to use library for ROC/AUC curves.
Matplotlib is mostly used for plotting things, so you'd need to calculate the curves first and then plot them with matplotlib. There seem to be multiple relevant Python modules:
scipy roc_curve
PyROC
CROC
yard