2/20/2023 0 Comments Plt a linein rI am new to R and apologize if this is a foolish question. I was running it with the "l", then came across one instructional site that had ommitted it, and thought, oh, well it IS somewhat redundant, so I took it out, and still, same result. Syntax: plot(x, y, type l, lty 1) lines(x, y, type l, lty 1) Parameters: x, y: coordinate vectors of points to join type: character indicating the type of plotting. After creating the matrix, now we will plot the lines and points. I realize lines() is missing type = "l" as well. R program to plot line graph x c (1,2,3,4,5,6,7,8,9,10,11) y c (22,13,5,9,25,22,26,1,9,10,2) plot function except x,y rest are optional plot (x, y, type'b', main'First Plot Example', sub'Line Graph', xlab'time', ylab'cost', asp1) When the above program is run, plot would be generated as a pdf file, by default. Plotting line and point on graph with different color. In this tutorial, we will learn how to set plot line width, with example programs. The key here is first to calculate the slope and the intercept correctly, and then use geomribbon and geomabline.So if you wish to calculate the slope in 0.1, I suggest you calculate the ratio between the y increment and x increment in the interval x 0.9 and x 0. Lines( ,date_sub$Sub_metering_2, col = "red"). To set plot line width/thickness in R, call plot () function and along with the data to be plot, pass required thickness/line-width value for the lwd parameter. I thought maybe it was because the information was on the y-axis, so I even tried When I use the same data for the lines in plot() replacing date_sub$Sub_metering_1 with date_sub$Sub_metering_2 (and _3 respectively) they both create line graphs. The initial plot works well, but then no new red or blue lines. That shouldn't have any effect on the y variable? (note: the x variable, re_date is a separate vector I've created after converting the date/time column in the original date_sub data frame. Lines(date_sub$Sub_metering_3, col = "blue") Lines(date_sub$Sub_metering_2, col = "red") plot(re_date, date_sub$Sub_metering_1, type = "l", xlab = "", ylab = "Energy sub metering") I've tried creating individual vectors for the data in the columns and using lines() with instead of pulling it out of the data frame, but that doesn't work, neither does extracting it directly from the data frame. I can create the initial plot but when I go to add lines(), nothing shows up. I'm trying to create a line graph using data from different columns in the same data frame.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |