Hi all,
I am reading this:
and I want to plot a histogram for monthly return of a Shanghai Composite Index based on this code:
using CSV, DataFrames
#Read the CSV file and transform it into a DataFrame
rain_data = CSV.read("./csv/historico_precipitaciones.csv", DataFrame)
#Rename the columns
colnames = ["Year", "Month", "mm", "Days"]
rename!(rain_data, Symbol.(colnames)) #Symbol is the type of object used to represent the labels of a dataset
#We use a dictionary to translate de Month names
translate = Dict("Enero" => "January" ,"Febrero" => "February" ,"Marzo" => "March" ,"Abril" => "April" ,"Mayo" => "May" ,"Junio" => "June" ,"Julio" => "July" ,"Agosto" => "August" ,"Septiembre" => "September" ,"Octubre" => "October" ,"Noviembre" => "November" ,"Diciembre" => "December")
for i in 1:length(rain_data[:,:Month])
rain_data[i,:Month] = translate[rain_data[i,:Month]]
end
# See the first 8 rows
# first(rain_data, 8)
begin
histogram(rain_data[:,"mm"], bins=20, legend=false, size=(450, 300))
title!("Monthly rainfall in Buenos Aires")
xlabel!("Rainfall (mm)")
ylabel!("Frequency")
end
But the csv is a monthly return that you can retrieve from
it is Shanghai Composite Index Data.
I want to know can the x axis have negative value too? Since the return can be negative, if the price falls from the previous month.
so just:
-
y-axis = the frequency (the number of months the return at certain interval occuring)
-
x-axis = the return in percent.
All is available in the investing.com website.
Thanks!