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

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.

Related

Processing xlsx files using Python Matplotlib and other libraries

Python newbie. It looks to me that in order to build a flexible data collection from xlsx it will be well worth my time to learn the Pandas DataFrame approach. More upfront learning time, but a much better platform once I have it working.
I've played around with some code examples, but I really want an expert to give me advice on the best approach.

how to extract data from plot produced by easy.py in libsvm-3.17

I just downloaded libsvm-3.17 abt two weeks ago. I tried heart_scale (dataset provided in the libsvm-3.17 package) with easy.py. An image or plot is produced (from gnuplot) to illustrate the best c and best gamma. I cannot post the image here because I am new here and do not have enough reputation.
I would like to ask from the many colors curves in the plot, how to extract from the plot that the best log2(c)=11 (which gives c=2048) and the best log2(gamma)=-13 (which gives gamma = 0.0001220703125).
Thank you very much.
the chosen parameters are reported by easy.py (cannot run it now, but you will find them). the plot is just a visual aid to manually verify the parameter neighborhood. with some experience you can interpret the diagram. without experience simply trust easy.py

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?

Drawing cartograms with Matplotlib?

In case somebody doesn't know: A cartogram is a type of map where some country/region-dependent numeric property scales the respective regions so that that property's density is (close to) constant. An example is
from worldmapper.org. In this example, countries are scaled according to their population, resulting in near-constant population density.
Needless to say, this is really cool. Does anyone know of a Matplotlib-based library for drawing such maps? The method used at worldmapper.org is described in (1), so it would surprise me if no one has implemented this yet...
I'm also interested in hearing about other cartogram libraries, even if they're not made for Matplotlib.
(1) Michael T. Gastner and M. E. J. Newman,
Diffusion-based method for producing density-equalizing maps,
Proc. Nat. Acad. Sci. USA, 101, 7499-7504 (2004). Available at arXiv.
There's this, though it's based and a different algorithm (and though it's on the ESRI site, it doesn't require ArcGIS). Of course, once you have the cartogram you can plot it in matplotlib.
Here is a Javascript plugin to make cartograms using D3. It is a good, simple solution if you are not too concerned about the regions being sized accurately. If accuracy is important, there are other options available that give you more freedom to play with the algorithm's parameters to get to a more accurate result.
Here are two great standalone programs I know of:
Scapetoad
Carto3F
Scapetoad is very easy to use. Just give it a shapefile, tell it which attribute to use for the scaling, and set a few accuracy parameters. If there is any doubt, this post describes the process.
Carto3F is more complex and allows for greater accuracy, though it is a bit trickier to figure out - lots of parameter settings without much documentation explaining them.
There is also a QGIS cartogram plugin, written in Python. Though I have not been able to get it to work, so cannot comment on that one.
In short, no. But Newman has an excellent little implementation of his and Gastner's method on his website. Installing it is easy and it works from the command line. Here's an example of a workflow using this software that worked for me.
Compute a grid of density estimates over some region, e.g. in Python. Store it as a matrix of numbers.
Run the cart program with your density matrix as input from the command line or from as subprocess in Python.
The program returns a list of new coordinates for each grid point.
Pipe your shapefile points through the interp program and into a new shapefile to get the transformed map.
There are nice instructions on the main page.
The geoplot.cartogram function in
Geoplot: geospatial data visualization — geoplot 0.2.0
says it is a high-level Python geospatial plotting library, and an extension to cartopy and matplotlib.
Try this library if you are using geopandas, it is quick and doesnt require much customization. https://github.com/mthh/cartogram_geopandas

What to beware of reading old Numarray tutorials and examples?

Python currently uses Numpy for heavy duty math and image processing.
The earlier Numeric and Numarray are obsolete, but still today there are many tutorials, notes, sample code and other documentation using them. Some of these cover special topics of interest, some are well written but haven't been updated or replaced, or are otherwise of use. Quite a bit is the same between Numeric, Numarray and Numpy, so I usually get good mileage out these older docs. Ocassionaly, though, I run into a line of code that results in error. Not often enough to remember how to get around it, but usually I figure it out at the cost of some time.
What are the main things to watch out for when relying on such older documentation for current Numpy use? Is there a list of how to translate the differences that exist?
Two good resources:
Numarray to numpy guide
Differences between Numeric and numpy