python - Set axis limits in matplotlib graph -


I have five periods with their possibilities and I want to simulate it with 200x times with Poisson distribution. I want to start X-X from -0, I tried, but I stock it with that code here: and there is no way to make it easier by the actions I made

  Import imported import matplotlib Pyplot import pylab import nypy as np to pylab import * data = [] list = 0 in j Ima (4000): totalOrder = 0 totalProduction = 0 in I (5): # calculation order mean = 105 order = NP Random.gamma (mean, 20000) totalOrder = totalOrder + order # Calculation of production output = numpy.random. Choice Production = Total Production + Product # Calculator New List List = List + Product - Order If List & Lt; (80, 100, 130, 150), p = [0.2, 0.50, 0.20, 0.1] 0: Inventory = 0 # Calculate the Fill Rate for the last 5 orders fr = Float (Total Productions) / Float (Total Order) if fr & gt; 1: fr = 1 # dataset data.append (fr) grid (right) xlabel ('fill rate') ylabel ('density') title ('system simulation for 20000 weeks)' Add FR in matplotlib.pyplot.hist data , Criterion = true) pylab.show ()    

Would you like to use axes For example, for example, consider some of your examples, to better understand what you can do with the module.

For your code, you must add:

  Ax = plt.gca () ax.set_xlim (0,1)   < P> For some optimization, I think that you are adding the same modules under different aliases (eg, you have salt and its nickname NP imported, which is also imported by Pylab). It tells me that you do not have much experience with language just as you continue to learn, you will eventually only reduce all those imports, such as  
  as imports NP import as matplotlib.pyplot plt   

and you can access these namespaces (like plt.show () , pylab.show Correlated right functions will call - Yellow is a thin veil of not more than a package of numpy and matplotlib.

There are some more customizations that you can do in your code (Like vector of loop), but seeing your current level, I think that will make it very complicated. Besides, the loop tells you what you are doing.

Maybe Just one tip: In the python, when you want to update a variable that is numeric (int, float, ...), then just do it:

  list = = output - order < / Code>  

This prevents you from typing list and thus lesser probability of errors are possible. In case you want to change your address.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -