Matplotlib - pandas - No xlabel and xticks for double axes in custom shapes

I had a similar question, which was answered earlier. However, he is different in using the Pandas package with him.

Here is my previous question: matplotlib - No xlabel and xticks for double axes in adjusted digits

So my question, like the last one, is why it does not show xlabel and xticks for first line diagrams when using this Python code.

Two notes:

  • I used subplotsinstead gridspec, but the same result.
  • If you uncomment any commented lines in this code that involve using Pandas along the axes in each diagram, xlabel and xticks will disappear!

import matplotlib.pyplot as plt
import matplotlib.gridspec as gspec
import numpy as np
import pandas as pd
from math import sqrt

fig = plt.figure() 
gs = gspec.GridSpec(2, 2)
gs.update(hspace=0.7, wspace=0.7)
ax1 = plt.subplot(gs[0, 0])
ax2 = plt.subplot(gs[0, 1])
ax3 = plt.subplot(gs[1, 0])
ax4 = plt.subplot(gs[1, 1])


x1 = np.linspace(1,10,10)


ax12 = ax1.twinx()
ax1.set_xlabel("Fig1")
ax12.set_xlabel("Fig1")
ax1.set_ylabel("Y1")
ax12.set_ylabel("Y2")
# pd.Series(range(10)).plot(ax=ax1)
ax12.plot(x1, x1**3)




ax22 = ax2.twinx()
ax2.set_xlabel("Fig2")
ax22.set_xlabel("Fig2")
ax2.set_ylabel("Y3")
ax22.set_ylabel("Y4")
# pd.Series(range(10)).plot(ax=ax2)
ax22.plot(x1, x1**0.5)


ax32 = ax3.twinx()
ax3.set_xlabel("Fig3")
ax32.set_xlabel("Fig3")
ax3.set_ylabel("Y5")
ax32.set_ylabel("Y6")
# pd.Series(range(200)).plot(ax=ax3)



ax42 = ax4.twinx()
ax4.set_xlabel("Fig4")
ax42.set_xlabel("Fig4")
ax4.set_ylabel("Y7")
ax42.set_ylabel("Y8")
# pd.Series(range(10)).plot(ax=ax42)



plt.subplots_adjust(wspace=0.8, hspace=0.8)
plt.show()
+3
1

Scimonster, , pandas, doublex.

doublex, pandas Dataframe (x, t plot). , pandas.

1. 2. pandas . 3. 4. .

,

0

Source: https://habr.com/ru/post/1627372/


All Articles