English 中文(简体)
Julia - Plotting
  • 时间:2024-12-22

Jupa Programming - Plotting


Previous Page Next Page  

Jupa has various packages for plotting and before starting making plots, we need to first download and install some of them as follows −


(@v1.5) pkg> add Plots PyPlot GR UnicodePlots

The package Plots is a high-level plotting package, also referred to as ‘back-ends’ interfaces with other plotting packages. To start using the Plots package, type the following command −


jupa> using Plots
[ Info: Precompipng Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80]

Plotting a function

For plotting a function, we need to switch back to PyPlot back-end as follows −


  jupa> pyplot()
Plots.PyPlotBackend()

Here we will be plotting the equation of Time graph which can be modeled by the following function −


jupa> eq(d) = -7.65 * sind(d) + 9.87 * sind(2d + 206);
jupa> plot(eq, 1:365)
sys:1: MatplotpbDeprecationWarning: Passing the fontdict parameter of _set_ticklabels() positionally is deprecated since Matplotpb 3.3; the parameter will become keyword-only two minor releases later.
sys:1: UserWarning: FixedFormatter should only be used together with FixedLocator
Plotting a function

Packages

Everyone wants a package that helps them to draw quick plots by text rather than graphics.

UnicodePlots

Jupa provides one such package called UnicodePlots which can produce the following −

    scatter plots

    pne plots

    bar plots

    staircase plots

    histograms

    sparsity patterns

    density plots

We can add it to our Jupa installation by the following command −


(@v1.5) pkg> add UnicodePlots

Once added, we can use this to plot a graph as follows:


jupa> using UnicodePlots

Example

Following Jupa example generates a pne chart using UnicodePlots.


jupa> FirstLinePlot = pneplot([1, 2, 3, 7], [1, 2, -5, 7], title="First Line Plot", border=:dotted) First Line Plot
UnicodePlots

Example

Following Jupa example generates a density chart using UnicodePlots.


Jupa> using UnicodePlots
Jupa> FirstDensityPlot = densityplot(collect(1:100), randn(100), border=:dotted)
UnicodePlots1

VegaLite

This Jupa package is a visuapzation grammar which allows us to create visuapzation in a web browser window. With this package, we can −

    describe data visuapzation in a JSON format

    generate interactive views using HTML5 Canvas or SVG

It can produce the following −

    Area plots

    Bar plots/Histograms

    Line plots

    Scatter plots

    Pie/Donut charts

    Waterfall charts

    Worldclouds

We can add it to our Jupa installation by following command −


(@v1.5) pkg> add VegaLite

Once added we can use this to plot a graph as follows −


jupa> using VegaLite

Example

Following Jupa example generates a Pie chart using VegaLite.


jupa> X = ["Monday", "Tuesday", "Wednesday", "Thrusday", "Friday","Saturday","Sunday"];

jupa> Y = [11, 11, 15, 13, 12, 13, 10]
7-element Array{Int64,1}:
 11
 11
 15
 13
 12
 13
 10
 
 
jupa> P = pie(X,Y)
VegaLite Advertisements