1

Python novice here.

I'm producing 2d contour plots using plotly on python - code below. I am looking at how GDP growth changes after a loan shock. Z_data is a 2D matrix with rows corresponding to months after a loan growth shock and columns corresponding to years. The data itself corresponds to the impact of the loan shock on GDP, that many months after the shock, in that year.

I would like to add 2x lines to my contour plot showing 1) Maximum impact and 2) Minimum impact - so basically taking the column-mean of the Z_data matrix.

Any suggestions on how to do this would be greatly appreciated. See below pic of what I'm producing, and an idea of what i'd like to achieve.

Thank you!

White lines/points for max, black for min or sth like that Output


import plotly.graph_objects as go
import numpy as np

fig = go.Figure(data =
    go.Contour(
        z=z_data , x=np.arange(2000.166667,2023,0.0833333333333333), colorscale ='Turbo',showscale=True
    ))

fig.update_layout(title='Discrete Impulse-Response of GDP to a Unit Acceleration in Loan Growth', autosize=True,
                  margin=dict(l=0, r=0, b=0, t=65)
 )
               

fig.show()

No clue how to approach this - tried to find the answer myself online but cannot. Apologies if its obvious and im missing.

  • This seems like a very cool project. I would like to help you if I can, but is there any chance you could share a sample of your dataset to make a reproducible example? [This](https://stackoverflow.com/questions/63163251/how-to-easily-share-a-sample-dataframe-using-df-to-dict) is one way you can share your data. – vestland Apr 19 '23 at 08:43

0 Answers0