Hi everyone,
I have a DataFrame with one date data and the other columns are just numbers.
I want to create a plot of two specific columns df.data1 and df.data3 against the date column on the x-axis.
When I try something like the following:
Plotting with PlutoPlotly is extremely easy if you are not looking for many ingredients in your plots. Moreover, you do not need to create a Date object (like you have to in some other plotting packages) if your data frame includes a column with dates that Julia accepts as a type of Date.
Suppose you have a data frame like the one in the figure below (USdata.csv).
Notice that the column Quarters is accepted as a Date type (you can by typing: typeof(USdata.Quarters) and because PlutoPlotly takes into account this information, the plotting is straightforward: For example, dates in the x-axis, and three columns in the y-axis (see first image below):
If instead you force a column with the name :Date to be inserted in the x-axis, but there is no column with that name, the plot will still be produced, but no dates will pop up in such axis (second image below)
Thank you so much for the very informative and helpful reply! Any chance you can share how to label each line? the automatic names trace 0, trace 1 .. are confusing, it’s better to use column names automatically or just manually write the labels.
begin
p1 = plot(USdata.Quarters, [USdata.GDP USdata.INV USdata.M2])
restyle!(p1,
name = ["GDP" "INV" "M2"],
line_color = ["BlueViolet" "maroon" "navy"]) # any other colors will do
relayout!(p1,
title_text = "My title using relayout but you can do it with Layout",
title_x = 0.5, # centers the title
xaxis_title = "Quarters", yaxis_title = " Billion dollars",
height = 450, width = 900) # in PlutoPlotly default will be height=400, width=Pluto window width
p1
end