However, assume now that the second dataset that you want to plot has x values ranging from 0 to 200. Once this is plotted, the graph will draw the x-axis with the 0-100 range. Let's say the first dataset that you plot has an x-value range of 0 to 100. Sometimes when we want to add multiple datasets to a single plot, it is important to correctly specify the size of the canvas. Note that if we were plotting just the scatter graph without lines, we could add more data points to it using the points() function instead of the lines() function. We can now add the lines for the second and third density using the lines() function. Normal Distribution Add Lines for the Second Normal Density > 圓 data plot(data$x,data$y1,type="l",main="Normal Distribution",xlab="x",ylab="y") We can do this using the seq() function in R. Generate x-axis dataįirst we will generate data for x-axis which will be a sequence of 200 evenly spaced numbers ranging from -5 to 5. Let's learn this with the help of an example where we will plot multiple normal distribution curves. Then we add the second data set using the points() or lines() function. To plot multiple datasets, we first draw a graph with a single dataset using the plot() function. Similarly, we may want to plot multiple normal distribution curves with different mean and standard deviations. For example, we may want to plot the daily returns from multiple stocks on a single chart to understand how they trend vis-a-vis each other. It's a common scenario to plot multiple datasets together on a single graph.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |