0

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:

user1317221_G
  • 15,087
  • 3
  • 52
  • 78
tijanicharles
  • 183
  • 3
  • 17
  • 4
    quick tip to improve the chances of a quick answer, it makes it smoother for people to help if you make your question [reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) then people don't have to go to the trouble of generating data to show how it may be accomplished. – user1317221_G Nov 18 '13 at 19:49
  • Take a look at the examples in [`?axis`](http://stat.ethz.ch/R-manual/R-devel/library/graphics/html/axis.html) – Jilber Urbina Nov 18 '13 at 19:50
  • Also look at http://www.statmethods.net/advgraphs/axes.html – rawr Nov 18 '13 at 19:56
  • 1
    I don't think I understand what the *"names"* are meant to be on the y-axis. Can you at least show us what `solar$Name` looks like? If they are not continuous data but character names then this plot seems a bit strange... – user1317221_G Nov 18 '13 at 19:59
  • Are you asking for a bar chart oriented horizontally? – Carl Witthoft Nov 18 '13 at 20:12
  • Here's a short list of the names returned when I type in solar$Name: [1] Alamosa WTF [2] Arvada Ralston Water Treatment Plant [3] Rifle Pump Station [4] NREL Mesa Top PV Project [5] Pima County Wastewater [6] The North Face [7] Western Riverside County Regional Wastewater Authority [8] Inlands Empire Utility Solar Farm – tijanicharles Nov 18 '13 at 23:17
  • The names are part of a list of Solar Panel arrays. the corresponding dates include the year each project has/will be completed – tijanicharles Nov 18 '13 at 23:21

1 Answers1

2

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) 
Troy
  • 8,581
  • 29
  • 32