-1

Few questions to fix my chart: How do I change the size of my axis labels so the numbers do not overlap. How do I change the Yaxis scale so it is in decimals as opposed to scientific numbers.

GGplot2 comes up with an error saying that my values are discrete why did R recognise the lists as discrete and not continuous and how do I change this.

Here is my code:

chart <- ggplot( data = alpha, aes(x = `Gini_coefficient_2016`, y = `GVA_per_worker_2017__£`,  color = `Region`), size = 10) 
    chart + geom_point(shape = 19,
                       alpha = 0.25,
                       position = position_jitter(width = 1, height = 0.5)) +     theme(axis.text=element_text(size=12),
            axis.title=element_text(size=5,face="bold")) + 
      theme(axis.title.x = element_text(size = 5), panel.grid.major = element_blank(), panel.grid =     element_blank(), panel.background = element_rect(fill = 'white', colour = 'white'))

Here is how the chart currently looks. All the issues as demonstratd in the questions can be found here.

pic

Thanks!

Community
  • 1
  • 1
Simba
  • 29
  • 1
  • 5
  • 1
    Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use `str()`, `head()` or screenshot)? You can use the [`reprex`](https://reprex.tidyverse.org/articles/articles/magic-reprex.html) and [`datapasta`](https://cran.r-project.org/web/packages/datapasta/vignettes/how-to-datapasta.html) packages to assist you with that. See also [Help me Help you](https://speakerdeck.com/jennybc/reprex-help-me-help-you?slide=5) & [How to make a great R reproducible example?](https://stackoverflow.com/q/5963269) – Tung Mar 31 '20 at 12:27
  • can you provide an example dataset? Otherwise it's close to impossible to troubleshoot by looking at your screen shot. do dput(head(alpha,20)) and paste the output as part of your post? or use an example dataset? – StupidWolf Mar 31 '20 at 14:22

1 Answers1

0

If you were to insert an as.numeric() around your variables, e.g.

ggplot( data = alpha, aes(x = as.numeric(`Gini_coefficient_2016`), y = as.numeric(`GVA_per_worker_2017__£`),  color = `Region`), size = 10) 
chart + geom_point(shape = 19,
                   alpha = 0.25,
                   position = position_jitter(width = 1, height = 0.5)) +     theme(axis.text=element_text(size=12),
        axis.title=element_text(size=5,face="bold")) + 
  theme(axis.title.x = element_text(size = 5), panel.grid.major = element_blank(), panel.grid =     element_blank(), panel.background = element_rect(fill = 'white', colour = 'white'))

I imagine that will solve your problem, without having access to the data/a reproducible example.

Jack
  • 173
  • 8
  • However, does not answer the questions – Simba Mar 31 '20 at 12:19
  • By the looks of your y axis (as best as I can see) your labels aren't numeric. E.g. starting from the bottom it goes 41419 to 43485 to 43650, which aren't equidistant apart. This implied that the y axis is categorical rather than numeric, so I was hoping that making your x & y numeric with as.numeric() would sort the issue out. Do you have a reproducible example of the issue? And does the plot look no different with the as.numeric functions added? – Jack Mar 31 '20 at 12:28