Yes, you want to add drop = FALSE
to your colour scale:
ggplot(subset(df,fruit == "apple"),aes(x = year,y = qty,colour = fruit)) +
geom_point() +
scale_colour_discrete(drop = FALSE)
More Related Contents:
- Remove ‘a’ from legend when using aesthetics and geom_text
- Force the origin to start at 0
- ggplot2 – bar plot with both stack and dodge
- Generate multiple graphics from within an R function
- Creating arbitrary panes in ggplot2
- How can I make consistent-width plots in ggplot (with legends)?
- Change bar plot colour in geom_bar with ggplot2 in r
- How to draw stacked bars in ggplot2 that show percentages based on group?
- Use stat_summary to annotate plot with number of observations
- Eliminating NAs from a ggplot
- ggplot2: How to specify multiple fill colors for points that are connected by lines of different colors
- Remove grid, background color, and top and right borders from ggplot2
- Setting y axis breaks in ggplot
- R knitr Markdown: Output Plots within For Loop
- Generate paired stacked bar charts in ggplot (using position_dodge only on some variables)
- heatmap with values (ggplot2)
- How to choose variable to display in tooltip when using ggplotly?
- Create heatmap with values from matrix in ggplot2
- facet_wrap add geom_hline
- Improve centering county names ggplot & maps
- Using different scales as fill based on factor
- Bars in geom_bar have unwanted different widths when using facet_wrap
- beautiful Pie Charts with R
- Generate ggplot2 boxplot with different colours for multiple groups
- Set number of columns (or rows) in a facetted plot
- photo alignment with graph in r
- Color points with the color as a column in ggplot2 [duplicate]
- Add raster to ggmap base map: set alpha (transparency) and fill color to inset_raster() in ggplot2
- Plotting pca biplot with ggplot2
- How to get a barplot with several variables side by side grouped by a factor