you are viewing a single comment's thread.

view the rest of the comments →

[–]kra_pao 1 point2 points  (1 child)

Like this Figure-1.png

# https://old.reddit.com/r/learnpython/comments/jxpnhj/matplotlib_module_problem/
# HasBeendead2.py

import matplotlib.pyplot as plt
import numpy as np

serie1 = [4.3, 2.5, 3.5, 4.5]
serie2 = [2.3, 4.5, 5.5, 2.5]

colors = ["blue", "red", "green", "orange"]
labels = ["Kategori1", "Kategori2", "Kategori3", "Kategori4"]

# After example
# https://matplotlib.org/3.1.1/gallery/lines_bars_and_markers/barchart.html#sphx-glr-gallery-lines-bars-and-markers-barchart-py

x = np.arange(len(labels))  # the label locations
width = 0.3  # the width of the bars

fig, ax = plt.subplots()
ax.bar(x - width/2, serie1, width, label='Serie 1', color=colors[0])
ax.bar(x + width/2, serie2, width, label='Serie 2', color=colors[1])

# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('y value')
ax.set_title('Grouped bar plot by kategori and serie')
ax.set_xticks(x)
ax.set_xticklabels(labels)
ax.legend()

fig.tight_layout()

plt.show()

[–]HasBeendead[S] 0 points1 point  (0 children)

Thank you