ggplot2 geom_col() does not show all items [duplicate] - r

This question already has answers here:
order of stacked bars in ggplot
(1 answer)
Force ggplot legend to show all categories when no values are present [duplicate]
(1 answer)
Can you put labels between horizontal bars?
(2 answers)
Closed last month.
I'm new to R and I'm trying to plot a small survey where I used a likert-scale.
I'm using
ggplot(Likert, aes(x=Anzahl, y=Frage, fill=Zustimmung)) + geom_col()
to display the data. There are probably better ways to do this and I probably should use data frames as I currently don't use them.
Now the actual Problem: The variable "Zustimung" has 5 different specifications but only 4 of them are shown and there are sorted weirdly.
I've found a few different posts online which seem to be regarding this issue but I can't understand them. Could someone please explain why this problem occures and how I can fix this?

Related

What function would I use in R to give more detail to this Chart? [duplicate]

This question already has answers here:
Increase number of axis ticks in ggplot2 for dates
(1 answer)
Adding date ticks to ggplot in R
(4 answers)
Closed 3 months ago.
I am fairly new to all of this, and I'm currently working with some datasets for fun/practice. I took a course on R, and it explained the basics and dove a little deeper into ggplot2, but I am at a point where I'm not quite sure what to do.
The dataset is commodity prices from 1960-2021. I am trying to visualize the cost of crude oil over that time, and currently I have a decent chart, but I am wanting to change the intervals on the tick marks so that it is more readable. I will also take any advice you guys have on how to make it look even better!
I've attached my current chart here. (https://i.stack.imgur.com/o9Z63.png)
This is my current code for the chart:
graph +
geom_point(size=2, alpha=.7) + geom_line() +
ggtitle("Oil Prices from 1960 to 2021") +
xlab("Years") + ylab("Oil Prices") +
theme(axis.title.x=element_text(color="Black", size=20),
axis.title.y=element_text(color="Black", size=20),
plot.title=element_text(color="Black", size=40))
I have tried to google the function, and have been given a bunch of answers, but I'm still not sure which one fits for what I'm trying to do. Ideally I would like the x axis (Years) to at a minimum show every 5-10 years, but the more descriptive the better. Also the Y axis (Prices) is very hard to read and tell what the actual price is.
I appreciate any and all help with this. I'm just working on it for the fun of it and to get some practice in, but figured I would use this resource and try to see what we can come up with.
Thanks!

Set limits in ggplot without loosing data points [duplicate]

This question already has an answer here:
Limit ggplot2 axes without removing data (outside limits): zoom
(1 answer)
Closed 1 year ago.
I want to focus on certain numbers above 0 in the y axis, so I tried to use
ylim(ymin=0,ymax=15)
but by doing this I removed values that are not in the figure
I tried to find another argument that will only "zoom" the figure but do not remove any actual value and the line will remain
Does anyone know any argument that will be valid?
E.g. figures
Try to use this instead of ylim()
coord_cartesian(ylim=c(0, 15))

color in ggplot2 legend not matching figure [duplicate]

This question already has answers here:
Why are the colors wrong on this ggplot? [duplicate]
(2 answers)
GGPLOT Color won't work [closed]
(1 answer)
Closed 4 years ago.
I have a problem getting the legend in ggplot2 to correspond to the color in the figure. And I have extra variables in the legend. I have read many posts on similar issues but unfortunately I have not been able to apply those to this situation - successfully at least. I tried using "fill" and "scale_fill_manual()", "theme()" and several others, but to no avail yet. Hopefully I am just missing something simple here, I appreciate any suggestions!
I am making a map and my code right now is:
ggplot()+ geom_map(data=world, map=world,aes(x=long, y=lat, map_id=region),color="white", fill="#7f7f7f", size=0.05)+
geom_point(aes(x=long.a,y=lat.a, size=var.p, color="red", alpha=0.5))
The plot looks like this:

Change month order using R and ggplot2 [duplicate]

This question already has answers here:
How do you specifically order ggplot2 x axis instead of alphabetical order? [duplicate]
(2 answers)
Closed 4 months ago.
So I'm having a pretty big problem. I'm trying to plot animal density (using two methods) against months.
When I plot one of the two methods, the months go out of order and I can't seem to get them to work.
In the end I want to have each of the two methods (camera.estimations and scat.estimations) on the same plot, with SD of each included and months in the right order. Any pointers from you lovely R folk would be awesome!
Here's my data:
https://docs.google.com/spreadsheet/ccc?key=0AjSTnjcF57_IdEhUXzFyQmtZaG5NXzdzTXZkbFdweXc&usp=sharing
I have used this post to help structure my ggplots before
How do you specifically order ggplot2 x axis instead of alphabetical order?
Manually setting the order of factors works but can be annoying, but is the best answer I have for you :)
without more information hope it helps!

Can you add texture to a box plot in ggplot2? [duplicate]

This question already has an answer here:
Pattern fills for graphs
(1 answer)
Closed 9 years ago.
Is there a command to add a pattern or texture to the fill of boxplots? I have my variables colour coded, but I want them to also be distinguishable in greyscale...
Many thanks!
As Hadley commented in a previous string. It is currently not possible.
https://stackoverflow.com/a/2901210/2762612

Resources