0

Scatterplot

Hello,

I am trying to create a scatterplot from the Titanic dataset, and I want to graph Age vs Fare, with a hue of PClass. I am trying to change the color of the Pclass, but the output is "Error: Discrete value supplied to continuous scale". I have looked at different posts, and have tried different approaches. It seems to work only when I don't use factor, but then the Pclass scale displays numbers other than 1, 2, and 3, which I don't want since there are only 3 values for Pclass.

Can someone explain what I am doing wrong with the code, and how I can fix this error?

Thank you in advance!

Hokage
  • 1
  • 2
  • factors in R are a kind of categorical variable that can optionally be ordered. But they're not continuous, so you either need to keep the value continuous and specify the breaks, or keep them as factors and pick a discrete color scale. – Jon Spring Oct 07 '22 at 04:27
  • Thank you for the information. Can you explain how I can adjust my code using the methods that you described? – Hokage Oct 07 '22 at 04:35
  • It will be much easier to help if you can share some sample data and code. Suggestions for how here: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Jon Spring Oct 07 '22 at 05:00
  • I included the attachment for the scatterplot code. – Hokage Oct 07 '22 at 05:05
  • Thanks, I saw that and made a suggestion for how to make it easier for people to help. – Jon Spring Oct 07 '22 at 05:06

0 Answers0