11/6/2023 0 Comments Ggplot line graph rLegend plays a crucial factor there in order to understand plotted data in a lucid way. When there are more than two lines in the same line graph, it becomes clumsy to read. We saw how to plot multiple lines in a single line chart. Plot(events1,type = "o",col = "red", xlab = "Month", ylab = "Event Count", In order to plot multiple lines in a single line chart, below is the R code for that: In a real-world scenario, there is always a comparison between various line charts. See the location, and you will find “Line_chart.png” will be created. Function: getwd() and setwd() can help you do so. Here the png file will be saved in your current working directory, which you always check and change as per your requirement. However, there come to the cases when you need to save it in the local system in the form of png files. The line graph drawn till now is in Rstudio pane. Plot(Vec,type = "o",xlab = "Month", ylab = "Event Count", main = "Event Count by Month")įig 3: Vector plot with customized labels 2. Here you will notice x label, y label has not been assigned, so the default names as came. Plot(Vec,type = "o") # Plot the bar chart. Simple Line Graph in R code (with Plot function): However, for ggplot, the library “ggplot2” needs to be installed and read that library like: “library(ggplot2)” in the R environment.įor installation in RStudio. For plot(), one need not install any library. The first function we will learn is plot() and another one would be ggplot. Before plotting the line graph, one needs to know whether the function one going to use is available in the R environment or has to be installed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |