Skip to main content

All Questions

2 votes
2 answers
12k views

Problem plotting a histogram of grayscale image in python

I have plotted a histogram of a grayscale image with matplotlib. But the histogram does not look like what I want. from matplotlib import pyplot as plt import numpy as np from PIL import Image im=...
4 votes
1 answer
2k views

Plot a histogram with constant bar widths but different bin sizes

I have a Python script which produces a single histogram of three data sets, where the bin sizes are provided as a list. The Python script sippet is as follows: bin_l=np.arange(0,14,1) bin_l=np....
16 votes
4 answers
18k views

Any way to create histogram with matplotlib.pyplot without plotting the histogram?

I am using matplotlib.pyplot to create histograms. I'm not actually interested in the plots of these histograms, but interested in the frequencies and bins (I know I can write my own code to do this, ...
7 votes
2 answers
10k views

Python: matplotlib - probability mass function as histogram

I want to draw a histogram and a line plot at the same graph. However, to do that I need to have my histogram as a probability mass function, so I want to have on the y-axis a probability values. ...
0 votes
1 answer
450 views

Overlapping density plots of multiple pandas data frame columns

import numpy as np import pandas as pd col1 = np.random.normal(0, 1, (1000, )) col2 = np.random.normal(0, 1, (1000, )) col3 = np.random.normal(0, 1, (1000, )) df = pd.DataFrame({'col1':col1, 'col2':...
2 votes
1 answer
266 views

How to plot multiple features with the same tag number in histogram plot

I have a text file including 8 features and 1 class. The data of my file is (data.txt): 1,1,3,2,1,1,1,3,HIGH 1,1,3,1,2,1,1,3,HIGH 1,1,1,1,3,3,1,2,HIGH 1,3,2,1,3,3,3,3,HIGH 1,3,1,2,3,1,2,1,HIGH 2,3,1,...
1 vote
0 answers
249 views

Plotting histogram with python 2.7 with log scale on y axis

I want to plot an histogram in python 2.7 whith a log scale on y axis: I wrote this code: plt.hist(lifes,100, log=True) But the results of histogram changed for the two axis like this: But in the ...
0 votes
0 answers
42 views

Histogram with counts of string variables in matplotlib [duplicate]

I want to plot a histogram with matploblib in Python, but my code doesn't seem to work. I imported data from a textfile with the following code: vragenlijst_data= np.genfromtxt('antwoorden.txt', ...
15 votes
1 answer
31k views

How to generate a word frequency histogram, where bars are ordered according to their height

I have a long list of words, and I want to generate a histogram of the frequency of each word in my list. I was able to do that in the code below: import csv from collections import Counter import ...
2 votes
1 answer
1k views

Column order reversed in step histogram plot

Passing a 2D array to Matplotlib's histogram function with histtype='step' seems to plot the columns in reverse order (at least from my biased, Western perspective of left-to-right). Here's an ...
0 votes
1 answer
64 views

How to create a historgram in matplotlib with values instead of data

Supposed I have the data set [1,1,1,2,2] and want the bins [1,2),[2,3) then I can use the follwoing code to generate a histogram: import matplotlib.pyplot as plt data = [1,1,1,2,2] values = [1,2,3] ...
0 votes
1 answer
1k views

TypeError when plotting histogram with Matplotlib

I'm trying to plot a histogram of a file of float numbers. The contents of the file look like this: 0.1066770707640915 0.0355590235880305 0.0711180471760610 0.4267082830563660 0.0355590235880305 0....
0 votes
1 answer
469 views

Meaning of colors in histogram matplotlib

l have a numpy variable called rnn1 of dimension(37,512) n, bins, patches = plt.hist(rnn1, histtype='stepfilled') l got the following histogram shape To what the different colors refer ? What is the ...
1 vote
1 answer
1k views

Symmetrize a histogram plot or array?

I have a histogram that runs from -5 to 5 that I can manipulate and plot as I please, and I use the following PDF's to run one-sample KS tests on it: norm, cauchy, students t, laplace. However, I ...
1 vote
1 answer
528 views

Convert a Histogram which has two variables plotted on it into a smooth Curve

Here is the code for generating the histogram. For the full code you can refer to this iPython Notebook # Splitting the dataset into malignant and benign. dataMalignant=datas[datas['diagnosis'] ==1] ...

15 30 50 per page