Line plot

Source code notebook

Line allows users to produce line plot. In the following example we read the stocks data from hard drive and then produce a simple line plot using Line and the sgplot function.

using InMemoryDatasets, DLMReader, StatisticalGraphics

Creating a data set

ds = Dataset(x=range(0,6,length=100))
modify!(ds, :x=>byrow(sin)=>:y)

sgplot(ds, Line(x=:x, y=:y))

Dubai Weather Users can pass multiple plot types to the sgplot function to produce an overlayed graph.

dubai_weather = filereader(joinpath(dirname(pathof(StatisticalGraphics)),
                                 "..", "docs", "assets", "dubai_weather.csv"),
                                 types=Dict(1 =>Date))

first(dubai_weather, 6)

6 rows × 4 columns

dateminmaxpressure
identityidentityidentityidentity
Date…?Float64?Float64?Float64?
12020-08-0233.3946.28996.6
22020-08-0333.044.11997.5
32020-08-0433.6142.11995.0
42020-08-0533.041.22992.8
52020-08-0632.038.72992.8
62020-08-0733.540.39993.4

User must pass type=:date to make sure that StatisticalGraphics uses an suitable scale for the corresponding axis

sgplot(dubai_weather, [Line(x=:date, y=:min), Line(x=:date, y=:max)], xaxis=Axis(type=:date))

The second axes can be used to measures with different scales on the same graph

sgplot(dubai_weather, [
                        Line(x=:date, y=:min),
                        Line(x=:date, y=:max),
                        Line(x=:date, y=:pressure, breaks=true, color=:red, y2axis=true)
                      ],
                        xaxis=Axis(type=:date))

This page was generated using DemoCards.jl and Literate.jl.