Graphics in Julia

Several packages exist to plot data and visualize data relations; Plots and PyPlot are some of the most commonly used:

  • PyPlot: (refer to the Installing and working with Jupyter section in Chapter 1, Installing the Julia Platform) This package works with no overhead through the PyCall package. The following is a summary of the main commands:
    • plot(y), plot(x,y) plots y versus 0,1,2,3 or versus x:loglog(x,y)
    • semilogx(x,y), semilogy(x,y) for log scale plots
    • title("A title"), xlabel("x-axis"), and ylabel("foo") to set labels
    • legend(["curve 1", "curve 2"], "northwest") to write a legend at the upper-left
    • grid(), axis( "equal") adds grid lines, and uses equal x and y scaling
    • title(L"the curve $e^sqrt{x}$") sets the title with a LaTeX equation
    • savefig( "fig.png"), savefig( "fig.eps") saves as the PNG or EPS image
  • Plots: (refer to the Adding a new package section in Chapter 1, Installing the Julia Platform) This is the favorite package in the Julia Computing community. It is a visualization interface and toolset that works with several backends, in particular GR (the default backend), PyPlot, and PlotyJS. To start using a certain backend, type gr() or pyplot() after you have given the command using PyPlots.

Plot styles can be adapted by so-called attributes (documented at http://docs.juliaplots.org/latest/attributes/). Some of the most used attributes are:

    • * xaxis, yaxis, and zaxis
    • line—to adapt line visualizations
    • fill—to fill surfaces with color and transparency
    • The subplot category to modify visualization of an entire plot
    • The plot category to modify visualization of an entire plot

Lots of other plots can be drawn in Plots, such as scatter plots, 2D histograms, and box plots. You can even draw in the REPL if you want to.

Comprehensive documentation and a tutorial can be found here: http://docs.juliaplots.org/latest/

We apply Plots to visualize data in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.144.65