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

Multilevel (Hierarchical) Axis #1573

Open
bray2016 opened this issue Mar 11, 2022 · 4 comments
Open

Multilevel (Hierarchical) Axis #1573

bray2016 opened this issue Mar 11, 2022 · 4 comments

Comments

@bray2016
Copy link

bray2016 commented Mar 11, 2022

Looking for a way to specify two separate axis layers for a line plot. Something like this figure. I've been able to find a lot of examples of how to do this with categorical distinctions, but not with a date variable.

@bjarthur
Copy link
Member

you mean you just want to plot multiple lines with a time axis?

julia> using Gadfly, Dates, DataFrames

julia> df = DataFrame(t=Date(2020):Month(1):Date(2021), x=1:13, y=2:14, z=3:15)
13×4 DataFrame
 Row │ t           x      y      z     
     │ Date        Int64  Int64  Int64 
─────┼─────────────────────────────────
   1 │ 2020-01-01      1      2      3
   2 │ 2020-02-01      2      3      4
   3 │ 2020-03-01      3      4      5
   4 │ 2020-04-01      4      5      6
   5 │ 2020-05-01      5      6      7
   6 │ 2020-06-01      6      7      8
   7 │ 2020-07-01      7      8      9
   8 │ 2020-08-01      8      9     10
   9 │ 2020-09-01      9     10     11
  10 │ 2020-10-01     10     11     12
  11 │ 2020-11-01     11     12     13
  12 │ 2020-12-01     12     13     14
  13 │ 2021-01-01     13     14     15

julia> plot(stack(df, [:x, :y, :z]), x=:t, y=:value, color=:variable, Geom.line)

Screen Shot 2022-03-12 at 9 24 48 AM

@bray2016
Copy link
Author

bray2016 commented Mar 28, 2022

Im more looking for a way to have month and then have year below each month for multiple years. Something like:

Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
----------------------- 2013------------------------------------------------------2014

Ignore the dashes, they are just to get the years in the right spots.

@Mattriks
Copy link
Member

Perhaps like in #1310 (comment), but with xgroup=:year, x=:month. That style would emphasize the year-to-year differences, if that is of interest.

@bray2016
Copy link
Author

Thanks for the suggestion. The issue is I am dealing with about 20 years worth of time series data, so I think showing 20 separate panels of yearly data could be a little overwhelming. Ideally, I could show it all on one graph so one could see the monthly variation for specific years as well as the aggregate trend across years

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

No branches or pull requests

3 participants