Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overview_plot Function Does not Plot Correctly #11

Open
brichard1638 opened this issue Aug 7, 2022 · 6 comments
Open

overview_plot Function Does not Plot Correctly #11

brichard1638 opened this issue Aug 7, 2022 · 6 comments
Assignees

Comments

@brichard1638
Copy link

It appears that the overview_plot function is not plotting correctly. In version 0.0.1.1, the following code does not plot correctly:
overview_plot(dat = toydata, id = ccode, time = year, xaxis = "Time Frame", color = "blue") + labs(title = "Hello World")

The output returns an x-axis label that reads "blue" and the line graphics in the plot are not colored correctly. I did load ggplot2 along with a labs geom to return a title. It is not known if adding this geom has contributed or is the principal cause of the issue.

@cosimameyer
Copy link
Owner

Hi @brichard1638,
Thanks for reaching out and opening the issue. We'll look into it - just to be sure: Are you using version 0.0.11? (As a development version from GitHub or as the CRAN version?)

@brichard1638
Copy link
Author

brichard1638 commented Aug 8, 2022 via email

@cosimameyer
Copy link
Owner

Hi @brichard1638,

Thanks! I had a look into your issue and here's an answer to your question:

  • overview_plot has a default color argument that requires a categorical variable. Here are some examples if you want to know more. If you add a string (blue) it behaves in a similar way as ggplot2
  • If you want to change the color your plot, just follow the ggplot2 logic and add layers :)

We first need some preparation:

toydata$dummy <- ifelse(toydata$year<1995, 0, 1)

which yields:
Screenshot 2022-08-08 at 20 49 51

We can now use dummy to plot it with overview_plot

overview_plot(dat = toydata, id = ccode, time = year, xaxis = "Time Frame", color = dummy)

Screenshot 2022-08-08 at 20 50 05

And with an additional layer:

 overview_plot(dat = toydata, id = ccode, time = year, xaxis = "Time Frame", color = dummy) + scale_color_brewer(palette="Dark2")

Screenshot 2022-08-08 at 20 59 48

I'll add it to our workflow descriptions on our website to make this clear (#13) - thanks for the suggestion! :)

When testing, adding the title with both ggtitle and/or labs works.

Let me know if this helps.

@brichard1638
Copy link
Author

brichard1638 commented Aug 8, 2022 via email

@cosimameyer
Copy link
Owner

Hi Brice,

Thanks for your reply. I understand your concerns about the possible overhead that may be caused in the current form of overview_plot when changing the color but it basically follows the layering logic of ggplot2 and is - as we believe - in itself quite flexible (and versatile because people tend to know ggplot2). The idea how we originally designed overview_plot was to differentiate differing time periods from each other easily (and these time periods were typically part of the dataset (created throughout the data wrangling process); so we always needed them anyways for the analysis at a later stage and they were no extra dimension that was added to the dataset).
I think the point you're coming from is an interesting new take on how to envision the overview_plot function - so your idea would be to basically allow an additional color argument that let's the user define the color of the plot? (also without providing any additional information in the form of differing time periods?) I'm curious to hear your thoughts on this! ☺️

Cosima

@brichard1638
Copy link
Author

brichard1638 commented Aug 10, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants