0

I have been trying to make a plot that shows how often a specific world region (Western Europe, North America, etc...) has been covered in an issue of a certain journal.

I'd like the x-axis to display the issue and the y-axis to display the count of times a region has been covered in that issue. I would like to create a stacked area chart, so I can see which region has been covered the most in which issue, and how these numbers change over time.

My data looks like this:

my dataset. "wreg" means "world region"

The observations that include data on other world regions (WE = Western Europe, EE = Eastern Europe, etc.) are not shown in the picture, but follow further down.

My code looks like this:

wreg_by_issue_plot <- ggplot(data = cov_by_issue_long, aes(x = issue, y = count, fill = wreg)) +
                  geom_area()

According to this tutorial my code should work, but it doesn't. Instead, I get the following outcome: my current plot

I know, the x-axis is still messy, but I can take care of that later. What I wonder is, why are the areas not being displayed?

Vinícius Félix
  • 8,448
  • 6
  • 16
  • 32
Firefly05
  • 11
  • 2
  • 1
    The issue is the x-axis - because your x axis is discrete, you would need to specify a `group` aesthetic to indicate which dots to connect. If you convert your `issue` column to something continuous (`Date` or `numeric` class), the `geom_area` issue will solve itself. – Gregor Thomas Nov 05 '20 at 14:11
  • 1
    Make sure your data aren't factors. – at80 Nov 05 '20 at 14:12
  • 1
    If you need more help, please post some sample data reproducibly - we can't very well demonstrate solutions on a picture of your data. `dput()` is a great way to share data that is copy/pasteable and preserves class and structure information - please post `dput(cov_by_issue_long[1:10, ])`. Or if you have `factor` columns and that is too long, `dput(droplevels(cov_by_issue_long[1:10, ]))` – Gregor Thomas Nov 05 '20 at 16:15

0 Answers0