Line plot
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)
date | min | max | pressure | |
---|---|---|---|---|
identity | identity | identity | identity | |
Date…? | Float64? | Float64? | Float64? | |
1 | 2020-08-02 | 33.39 | 46.28 | 996.6 |
2 | 2020-08-03 | 33.0 | 44.11 | 997.5 |
3 | 2020-08-04 | 33.61 | 42.11 | 995.0 |
4 | 2020-08-05 | 33.0 | 41.22 | 992.8 |
5 | 2020-08-06 | 32.0 | 38.72 | 992.8 |
6 | 2020-08-07 | 33.5 | 40.39 | 993.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.