Hi all,
I have a datset, which I want to plot:
Percentage_low_income / Distance / City
50.8 /5/ Amsterdam
50.9 /10/ Amsterdam
45.5 /Municipality/ Amsterdam
53.1 /5 / Rotterdam
53.1 /10/ Rotterdam
39 /Municipality/ Rotterdam
51.6 5 The_Hague
50.1 10 The_Hague
36.7 Municipality The_Hague
48.1 5 Utrecht
48 10 Utrecht
40.5 Municipality Utrecht
50.6 5 Total
50.5 10 Total
40 Municipality Total
I want to have the Distance on the x-axis, the percentage on the y-axis and the cities as colour. But, to increase the readability of the graph I also want to include smooth lines that go through all three points per city. My code:
ggplot(data = dat, mapping = aes(x = Distance,
y = Percentage_low_income,
color = City)) +
geom_point() +
geom_smooth(method = "auto", se = FALSE)
However, it does not seem to plot the smooth lines, can anyone help me out?
Your code appears fine (with appropriate data), so the issue is with your data...
please see this FAQ on the correct way to sure your data.
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
system
Closed
May 6, 2021, 3:17pm
3
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.