0

this is my code:

fig, ax = plt.subplots(1,2, figsize = (30, 8))
g1 = sns.lineplot(data = plsWeekly , x = 'Date', y = 'Close', ax=ax[0])
plt.xticks(rotation=70)
g2 = sns.lineplot(data = asxWeekly , x = 'Date', y = 'Close', ax=ax[1])
plt.xticks(rotation=70)

and, this is the output:

subplot output

i just tried running the code and I expected that both x labels for the two(2) plots are gonna rotate by 70

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
  • 1
    Check this [answer](https://stackoverflow.com/a/52461208/12639940) – Kayvan Shah Mar 28 '23 at 07:50
  • try this: `fig, ax = plt.subplots(1,2, figsize = (30, 8))` `ax[0].xticks(rotation=70)` `ax[1].xticks(rotation=70)` `g1 = sns.lineplot(data = plsWeekly , x = 'Date', y = 'Close', ax=ax[0])` `g2 = sns.lineplot(data = asxWeekly , x = 'Date', y = 'Close', ax=ax[1])` – wowonline Mar 28 '23 at 07:51
  • @KayvanShah sorry, but, can you expound more? Python is asking definition for the xticks – Aris dela Cruz Mar 29 '23 at 08:54

1 Answers1

0

Set the current axes as needed before calling plt.xticks(rotation=70), e.g. plt.sca(ax[0])

Julien
  • 13,986
  • 5
  • 29
  • 53