rtime-seriesscatter-plotname-value

R plot, actual Row values instead of row numbers


I have a data set containing names of Solar Panel arrays, their dates of completion and location (long/lat).

I created an rplot with the time of completion on the x axis and the names of each array on the y axis. Here in lies the problem - the actual names are not displayed but the number designation for each row is. Is there a way to get the names listed on the y axis instead of the numbers? ![Names are supposed to show on the y axis, the years show up fine on the x axis]

Heres the code I used to make my rplot:

plot(solar$Year.completed, solar$Name, xlim=c(1990, 2025))

I am also considering making adding more granularity (if that's even a word to the x axis)

Thanks to whomever can help with this.

Here is what the plot looks like:

Here is what the plot looks like:


Solution

  • Yup as everyone says, it's a lot easier if you can include data. But probably what you want is this:

    plot(solar$Year.completed, solar$Name, xlim=c(1990, 2025), yaxt="n")
    axis(2, at=1:length(unique(solar$Name)), labels=unique(solar$Name), cex.axis=0.5, las=2)
    

    in the first line, yaxt="n" gets rid of the default y axis labels

    the second line creates a series of points for each unique value of solar$Name

    2 (first argument) means it's the y axis

    cex.axis reduces the font size (because it looks like you have a lot of points)

    las-2 makes the labels perpendicular (again you probably need the space)

    and if you want granularity on the x-axis, you can do something similar (i.e. add xaxt="n" and create a custom x axis:

    plot(solar$Year.completed, solar$Name, xlim=c(1990, 2025), yaxt="n", xaxt="n")
    axis(2, at=1:length(unique(solar$Name)), labels=unique(solar$Name), cex.axis=0.5, las=2)
    axis(1, at=1990:2025, labels=1990:2025, cex.axis=0.7, las=2)