How can I shift the histogram to the right?


alagnak32

I have a 1D array of histograms with bin boundaries:

bins = np.arange(1, 6,2)
data = np.array([1,2,3,4,4,4,3,2,3,3,3])
plt.hist(data, bins=bins, histtype='step')

But I want to move the histogram horizontally by 1 unit to the right on the x-axis, how can I do it? I don't want the shape of the bin boundaries to change, just the entire histogram.

I tried doing:

x0 = 1
plt.hist(data+x0, bins=np.arange(1+x0, 6+x0,2+x0), histtype='step')

But it changes the bounds of the box. How can I fix it?

tom

You're close, but you np.arangedon't want to increase the step size. so:

plt.hist(data+x0, bins=np.arange(1+x0, 6+x0, 2), histtype='step')

Two graphs:

enter image description here

Related


How can I shift the histogram to the right?

alagnak32 I have a 1D array of histograms with bin boundaries: bins = np.arange(1, 6,2) data = np.array([1,2,3,4,4,4,3,2,3,3,3]) plt.hist(data, bins=bins, histtype='step') But I want to move the histogram horizontally by 1 unit to the right on the x-axis, how

How can I shift the histogram to the right?

alagnak32 I have a 1D array of histograms with bin boundaries: bins = np.arange(1, 6,2) data = np.array([1,2,3,4,4,4,3,2,3,3,3]) plt.hist(data, bins=bins, histtype='step') But I want to move the histogram horizontally by 1 unit to the right on the x-axis, how

How can I shift the histogram to the right?

alagnak32 I have a 1D array of histograms with bin boundaries: bins = np.arange(1, 6,2) data = np.array([1,2,3,4,4,4,3,2,3,3,3]) plt.hist(data, bins=bins, histtype='step') But I want to move the histogram horizontally by 1 unit to the right on the x-axis, how

How can I shift the histogram to the right?

alagnak32 I have a 1D array of histograms with bin boundaries: bins = np.arange(1, 6,2) data = np.array([1,2,3,4,4,4,3,2,3,3,3]) plt.hist(data, bins=bins, histtype='step') But I want to move the histogram horizontally by 1 unit to the right on the x-axis, how

How can I shift the histogram to the right?

alagnak32 I have a 1D array of histograms with bin boundaries: bins = np.arange(1, 6,2) data = np.array([1,2,3,4,4,4,3,2,3,3,3]) plt.hist(data, bins=bins, histtype='step') But I want to move the histogram horizontally by 1 unit to the right on the x-axis, how

How can I fix the histogram

aa I am trying to draw a very simple histogram using python. Here is my code: from numpy import * from matplotlib.pyplot import* from random import* nums = [] N = 10 for i in range(N): a = randint(0,10) nums.append(a) bars= [0,1,2,3,4,5,6,7,8,9] hist(

How can I fix the histogram

aa I am trying to draw a very simple histogram using python. Here is my code: from numpy import * from matplotlib.pyplot import* from random import* nums = [] N = 10 for i in range(N): a = randint(0,10) nums.append(a) bars= [0,1,2,3,4,5,6,7,8,9] hist(

How can I reduce the width of the histogram?

Itsuyama I have plotted a histogram of diagnostics, which I modeled as a Poisson distribution in python. I need to reduce the width of the rectangles in the output graph. I wrote the following line in python. I need the width reduction parameter for this line

How can I rename the xlabel for this histogram?

Jaffet Leon I'm making a histogram for a database about household income and education level and everything is fine, but when I try to rename the x labels, I simply can't: cces$faminc_new1 = recode(cces$faminc_new, "1" = "Less than $10

How can I rename the xlabel for this histogram?

Jaffet Leon I'm making a histogram for a database about household income and education level and everything is fine, but when I try to rename the x labels, I simply can't: cces$faminc_new1 = recode(cces$faminc_new, "1" = "Less than $10

How can I reduce the width of the histogram?

Itsuyama I have plotted a histogram of diagnostics, which I modeled as a Poisson distribution in python. I need to reduce the width of the rectangles in the output graph. I wrote the following line in python. I need the width reduction parameter for this line

How can I make this histogram in ggplot/R?

Crimea Please find My data qbelow . I have two covariates: q$Studieand q$best.respcorresponding to each of the five different studies reporting the best response after a certain treatment. q$best.respThere are three levels table(q$best.resp) 0 1 2 62 42

How can I represent the classes on the histogram with colors?

Subhankar Nayak I have a column in a dataset which I represent with a pyplot.hist graph. Use grey as a trash can. Another column by which I want to divide the graph is called "Class". There are two categories (0 and 1) in the Category column. I would like to r

How can I rename the xlabel for this histogram?

Jaffet Leon I'm making a histogram for a database about household income and education level and everything is fine, but when I try to rename the x labels, I simply can't: cces$faminc_new1 = recode(cces$faminc_new, "1" = "Less than $10

How can I create a histogram in R?

sara I'm new to working in Unix, so I need help on how to put a histogram together using R in Linux environment? File: 48302 50 0 48303 46 0 48304 45 0 48305 41 15 48306 44 21 48307 74 0 48308 71 0 48309 35 19 48310 66 0 48311 26

How can I rename the xlabel for this histogram?

Jaffet Leon I'm making a histogram for a database about household income and education level and everything is fine, but when I try to rename the x labels, I simply can't: cces$faminc_new1 = recode(cces$faminc_new, "1" = "Less than $10

How can I represent the classes on the histogram with colors?

Subhankar Nayak I have a column in a dataset which I represent with a pyplot.hist graph. Use grey as a trash can. Another column by which I want to divide the graph is called "Class". There are two categories (0 and 1) in the Category column. I would like to r

How can I make this histogram in ggplot/R?

Crimea Please find My data qbelow . I have two covariates: q$Studieand q$best.respcorresponding to each of the five different studies reporting the best response after a certain treatment. q$best.respThere are three levels table(q$best.resp) 0 1 2 62 42

How can I represent the classes on the histogram with colors?

Subhankar Nayak I have a column in a dataset which I represent with a pyplot.hist graph. Use grey as a trash can. Another column by which I want to divide the graph is called "Class". There are two categories (0 and 1) in the Category column. I would like to r