Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Matplotlib bar chart

I have a problem trying to display a bar chart.
Using OpenCV "reduce" method I obtain an array (like an histogram). This method computes the vertical projection so it's basically an histogram.

import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt

image = cv.imread("image-test.png",cv.IMREAD_GRAYSCALE)
histo = cv.reduce(image,0,cv.REDUCE_AVG)
imageWidth = histo.shape[1]
Now I want to display the image and the array (as a bar chart).
#Show image
plt.imshow(image,cmap = 'gray')
plt.xticks([]), plt.yticks([])

#Show histogram
X-axis is 0 to "imageWidth-1" and Y-axis is 0 to 255 as the image is grayscale and "reduce" is computed as average.

The image is shown as expected but the histogram not.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Rename labels of a bar chart Matplotlib smalatray 1 3,369 Jul-01-2020, 01:48 AM
Last Post: hussainmujtaba
  Spacing pie chart colours evenly in matplotlib? Giovanni_diJacopo 1 2,435 Jul-12-2019, 12:31 PM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020