I'm plotting a graph using this
plot(dates,returns)
I would like to have the returns
expressed as percentages instead of numbers. 0.1
would become 10%
. Also, the numbers on the y-axis appear tilted 90 degrees on the left. Is it possible to make them appear horizontally?
MatPlotLib with PythonCreate a list of numbers as y. Create a number of bins. Plot a histogram using hist() method, where y, bins, and edgecolor are passed in the argument. Store the patches to set the percentage on Y-axis.
Here is one way using las=TRUE
to turn the labels on the y-axis and axis()
for the new y-axis with adjusted labels.
dates <- 1:10
returns <- runif(10)
plot(dates, returns, yaxt="n")
axis(2, at=pretty(returns), lab=pretty(returns) * 100, las=TRUE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With