using pgf backend to matplotlib in julia - matplotlib

I started using Julia to analyse some data, which works perfect.
I also use PyPlot / Matplotlib for plotting, which I got working as well.
Now, these plots need to find their way into my latex document, which I want to achieve using the matplotlib pgf backend. It also works, but I really have no idea how to pass arguments to
mpl.rcParams.update(parameters)
Is there somebody skilled out there in the Julia community who can tell me how to achieve this?
EDIT2:
short update on the issue: Setting rc-options work by setting them in the following way:
PyPlot.matplotlib[:rc]("text", usetex=true) # here: allow tex rendering

Related

Geoviews bokeh vs matplotlib for plotting large xarrays

I am trying to plot a large xarray dataset of x=1000 by y=1000 for t=10 different timestamp in Google Colab.
See the following example notebook:
https://colab.research.google.com/drive/1HLCqM-x8kt0nMwbCjCos_tboeO6VqPjn
However, when I try to plot this with gv.extension('bokeh') it doesn't give any output...
When gv.extenstion('matplotlib') does correctly show a plot of this data.
I suppose it has something to do with the amount of data bokeh can store in one view?
I already tried putting dynamic=True, which does make it work. But for my use case the delay in viewing different timestamps is not really desirable. Same goes for datashader regrid, which makes it run faster, but the delay in viewing different timestamps is not wanted.
Is there a way to plot this large xarray with bokeh making it as smoothly visible and slidable as with matplotlib?
Or are there any other ways I can try and visualise this data interactively (on a web app)?

Plotting in julia: Lack of extensive and easily undestandable documentation?

As a physics major I am by no means good at coding but it suffices for modeling stuff. Plotting always ends up a beeing super annoying. It´s easy enough to look up stuff in the the Julia documentation if needed.
With plotting it´s a totally different story. There is just no good ressources to learn handling the available plotting packages.
I´m lost. There is proper documentation for PyPlot for example but only for Python and the code won´t work in Julia. Then there a few examples that obivously do not answer all my questions. Am I missing something? I feel stupid but also know that everyone around me spends to much time on plotting, too.
Any advice on were to look up stuff?
thanks in advance
Plotting in Julia is provided by packages. So you will not find plotting docs in the main documentation for julia.
There are a number of plotting packages to choose between - it's just a question of picking the one you prefer. Here is the documentation for most of the more used packages:
Plots: https://docs.juliaplots.org/latest/
Makie: https://makie.juliaplots.org/dev/
PlotlyJS: http://spencerlyon.com/PlotlyJS.jl/
VegaLite: https://www.queryverse.org/VegaLite.jl/stable/
PGFPlotsX: https://kristofferc.github.io/PGFPlotsX.jl/dev/
Gadfly: http://gadflyjl.org/stable/
GR: https://gr-framework.org/julia.html
UnicodePlots (for plotting in terminal): https://github.com/Evizero/UnicodePlots.jl
For PyPlot the matplotlib syntax should work. It's not clear from your question why it doesn't for you. So there should be ample resources.

PyPlot "plot()" function fails in julia 0.4.5 on Ubuntu 16.04

I am working with a program that is meant to take a few parameters and use a genetic algorithm to optimize a five-layer mirror coating according to said parameters. Just before termination, the program is meant to display a plot of the theoretical reflectivity of the mirror over a range of wavelengths. The last four lines of the program are:
plot(lam,rf)
xlabel("wavelength(AA)")
ylabel("reflectivity")
title("Broadband reflectivity")
When I run this from the command line (sudo julia Broadband.jl), the plot never displays; I put a few println() functions in there and there is output just before and just after plot(lam,rf).
Perhaps the strangest part is the fact that I copied the entirety of the code, pasted it to the terminal and ran it directly from julia (julia> [ENTIRETY OF .JL FILE]), and the plot displayed. Does anyone know what I'm missing?
Please note the following from the PyPlot README:
If you use PyPlot from an interactive Julia prompt, such as the Julia command-line prompt or an IJulia notebook, then plots appear immediately after a plotting function (plot etc.) is evaluated.
However, if you use PyPlot from a Julia script that is run non-interactively (e.g. julia myscript.jl), then Matplotlib is executed in non-interactive mode: a plot window is not opened until you run show() (equivalent to plt.show() in the Python examples).
Thus, you must call show() for your plot to display when run from the command line.

PyPlot in Julia only showing plot when code ends

I have recently begun learning to use Julia, converting over from Matlab/Octave. I decided that the best way to get some experience was to convert some code I was already working on i Octave - a Newton solver for a complicated multidimensional problem. I have been able to convert the code over successfully (and with noticeable speedup relative to Octave, without devectorisation or other performance-based changes), with only one issue arising.
I have chosen to use PyPlot for plotting, due to its similarity to Matlab/Octave's plotting functionality. However, there is some behaviour from PyPlot that is undesired. I use the plotting function to display the current state of the vector I am trying to get to zero (using the Newton solver part of the code), so that I can see what it is doing, and adjust the code to try to improve this behaviour. I input the number of Newton steps to take before the code stops, and then I can make adjustments or re-issue the command to continue attempting to converge.
I have the code set up to plot the current state every few steps, so that I can, for instance, have the code take 200 steps, but show me the status after every 10 steps. In Octave, this works perfectly, providing me with up-to-date information - should the behaviour of the code not be desirable, I can quickly cancel the code with Ctrl-C (this part works in Julia, too).
However, Julia does not produce or update the plots when the plot() command is used; instead, it produces the plot, or updates it if the plot window is already open, only when the code finishes. This entirely defeats the purpose of the intermittent plotting within the code. Once the code has completed, the plot is correctly generated, so I know that the plot() command itself is being used correctly.
I have tried adding either draw() or show() immediately after the plot command. I have also tried display(gcf()). None of these have modified the result. I have confirmed that isinteractive() outputs "true". I have also tried turning interactivity off (ioff()) and switching whether to use the python or julia backend (pygui(true) and pygui(false)), with no effect on this behaviour.
Have I missed something? Is there another package or option that needs to be set in order to force PyPlot to generate the current plot immediately, rather than waiting until Julia finishes its current code run to generate the plot?
Or is it perhaps possible that scope is causing a problem, here, as the intermittent plotting happens inside a while loop?
I am using xubuntu 12.10 with Julia 0.2.1.
PyPlot defaults to this behavior in the REPL. To make it show the plots as they are plotted type ion(). To turn it off again type ioff().
ion() is only effective for the current season so if you want it to stay on across sessions just add it to your .juliarc file.
If you're using iPython ion() will plot to a new window but ioff() will plot inline.

Plotting data in real time

I have a program which outputs to the terminal a number, one line at a time.
My goal is to have something else read these numbers and graph them in a line plot in real time. matplotlib and wxpython have been suggested, but I'm not sure how to go about implementing these.
See the following links:
What is the best real time plotting widget for wxPython?
Minimalistic Real-Time Plotting in Python
http://eli.thegreenplace.net/2008/08/01/matplotlib-with-wxpython-guis/
http://wxpython-users.1045709.n5.nabble.com/real-time-data-plots-td2344816.html
As some of those point out, you might be able to use wx's PyPlot for something really simple or use Chaco.
I really like this library for HTML5 graphing. Here is demo of real time updates: http://dygraphs.com/gallery/#g/dynamic-update
Are you simply asking for recommendations on plotting libs?