John
John

Reputation: 329

How to make a vertical stem plot?

I have the next stem plot

plt.stem(m)

stem plot 1

and I want it but 90 degrees clockwise rotated. I've tried with

plt.stem(m,np.arange(m.size))

And obtain the next plot

stem plot 2

The expecting result it's something like the R(t) of the next image: https://subsurfwiki.org/images/4/43/Convolutional_model.png

Upvotes: 0

Views: 718

Answers (1)

jylls
jylls

Reputation: 4695

With matplotlib>= 3.4.0 (release notes here), you can specify orientation='horizontal' in the stem function (see doc here):

Example below from the doc:

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0.1, 2 * np.pi, 41)
y = np.exp(np.sin(x))

plt.stem(x,y, orientation='horizontal')
plt.show()

enter image description here

and:

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0.1, 2 * np.pi, 41)
y = np.exp(np.sin(x))

plt.stem(x,y, orientation='vertical')
plt.show()

enter image description here

Upvotes: 1

Related Questions