I need to find a way how to reference axes within matplotlib.figure.Figure
object in order to add axhline(s) to one of the plots. I am using a plot_joint from the package MNE to create an EEG butterfly plot with a couple of topoplots. The lines will serve to showcase windows of statistical significance in the butterfly plot. Thanks!
Asked
Active
Viewed 504 times
1

ayasugihada
- 329
- 1
- 2
- 13
-
1`fig.axes[0].axhline(...)` – ImportanceOfBeingErnest Jan 13 '20 at 00:56
-
I have tried this before (using y, xmax, ymax args). It prints out `
` but fig.show() shows the same old plot. Any idea what might went wrong? – ayasugihada Jan 13 '20 at 01:03 -
1No, but that's no wonder without seeing any code. – ImportanceOfBeingErnest Jan 13 '20 at 01:04
-
Sure, will have to try to simulate some data later. With EEG it is always a bit pain. Anyways, thanks for now. – ayasugihada Jan 13 '20 at 01:09
-
It could help to add `zorder=3` (or some higher number) to force the lines to be shown on top of the rest of the image. Also, take care that in [`axhline(y=0, xmin=0, xmax=1)`](https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.axhline.html) the `y` is expressed in the data units of the y-axis, while the `xmin` and `xmax` go from 0 to 1, from left to right. – JohanC Jan 13 '20 at 01:12
-
1@ayasugihada A first step could be to show the code without the data. And give a good description how the data looks like. – JohanC Jan 13 '20 at 01:14
-
Marvelous, zorder seems to have solved the issue. Thanks a ton JohnC! – ayasugihada Jan 13 '20 at 06:52
1 Answers
0
Either of these 2 should work, depends on your setup of figure and axes:
fig.axes[0].axhline(...)
OR
ax.axhline(...)
credit to @ImportanceOfBeingErnest for the inspiration

PJ_
- 473
- 5
- 9