Introduction to Data Visualization with Julia
Gustavo Vieira Suñe
Data Analyst
# Create a violin plot violin( streaming.Fav_genre, streaming.Insomnia, framestyle=:grid, label=false, linewidth=0,
# Fill properties fillcolor=:purple, fillalpha=0.75,
# Permute the axes permute=(:x, :y),
# Remove grid lines grid=:off, )
xlabel!("Self-Reported Insomnia")
plot(x, y)
points are a series of the :line
type:line
, :scatter
, :histogram
, :density
, :bar
scatter(x, [y1 y2])
has two series of type :scatter
# Create a violin plot plot( streaming.Fav_genre, streaming.Insomnia, framestyle=:grid, label=false, linewidth=0, fillcolor=:purple, fillalpha=0.75, permute=(:x, :y), grid=:off,
# Specify series type seriestype=:violin, )
xlabel!("Self-Reported Insomnia")
@recipe function f( ::Type{Val{:my_hviolin}}, x, y, z )
# Series type seriestype := :violin
# Customization options framestyle := :grid label := false linewidth := 0 fillcolor := :purple fillalpha := 0.75 permute := (:x, :y) end
::Type{Val{:my_hviolin}}
defines my_hviolin
as the series recipe name
x, y, z
represent the series data
seriestype
gives the type of the series used in the recipe
Customization arguments set with :=
# Use recipe plot( streaming.Fav_genre, streaming.Insomnia, # Specify series recipe seriestype=:my_hviolin, )
xlabel!("Self-Reported Insomnia")
# Define my_hviolin function @shorthands my_hviolin
# Use recipe my_hviolin( streaming.Fav_genre, streaming.Insomnia ) xlabel!("Self-Reported Insomnia")
my_hviolin(streaming.Fav_genre,
streaming.OCD)
xlabel!("Self-Reported OCD")
my_hviolin(streaming.Fav_genre,
streaming.Anxiety)
xlabel!("Self-Reported Anxiety")
Introduction to Data Visualization with Julia