0

i am new to this so please be tolerant for mistakes i am making. i'll try to describe my problem as good as i can. feel free to give me advises on how to improve my description of the problem.

my goal: i do have this timeseries plot about different kinds of air quality values for 3 different locations. one graph for each pollutant. in addition i do have a xarray dataarray with different variables from which i only use the one called 'kind'. i was thinking of a horizontal bar parallelly attached to each graph inside the same plot, just indicating 3 different colors which depend on the value of the array 'kind' ('A', 'B', 'NaN') for every single timestamp.

for the timeseries i use matplotlib.

i am grateful for any help provided!

edit: this is what i'm looking for.. a horizontal bar linked to the same xaxis so it gives me additional info on my time series values. the additional information comes from another file (xarray.dataarray)

enter image description here

Michael Delgado
  • 13,789
  • 3
  • 29
  • 54
joeseph
  • 1
  • 1
  • 2
    Hi there. Welcome to stack overflow! When asking questions, please don’t upload images of code, data, errors, etc. instead, you can use e.g. `print(df)` to print your dataframe or dataset and paste that into your questions as a formatted code block. For your question, can you show us what you’ve tried and what’s not working? Xarray has a great [plotting guide](https://docs.xarray.dev/en/stable/user-guide/plotting.html), and there are more examples on the [xarray tutorials](https://tutorial.xarray.dev/intro.html) site. Good luck! – Michael Delgado Oct 17 '22 at 14:39
  • my problem already starts with finding out whether it's possible to implement an 'independent' graph/bar into another one (like same axes) or if i have to generate two different graphs inside the same figure? i want to have those two aligned and positioned very close together. – joeseph Oct 18 '22 at 07:11
  • Does this answer your question? [Adding a second y-axis related to the first y-axis](https://stackoverflow.com/questions/43149703/adding-a-second-y-axis-related-to-the-first-y-axis) – Michael Delgado Oct 18 '22 at 18:10
  • please ask one question at a time - if you want to plot pandas columns with a secondary axis you can use the matplotlib ax.twinx method I linked to above, or use the `secondary_y` argument to `df.plot`: see [Pandas Secondary Axis](https://stackoverflow.com/questions/46063379/pandas-secondary-axis) – Michael Delgado Oct 18 '22 at 18:12
  • @MichaelDelgado quite interesting but i'm afraid to say it's not exactly what i'm looking for i guess. i am going to edit my post.. thought a visualisation would make it much more clear (: – joeseph Oct 18 '22 at 18:52
  • Ok. Can you check out the guide to creating an [mre] and also the [pandas-specific guide](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples)? This is a pretty complicated plot and it would be great if you could tee up the data and code for us. Show us what you’ve tried, where you’re stuck, and we’ll see if we can get you the rest of the way there. – Michael Delgado Oct 18 '22 at 19:12

0 Answers0