python - Pyplot: using percentage on x axis -


I have a line chart based on the simple list of numbers. By default, X-X is the only one increment for each value that has been plotted. I would rather be a percentage but can not understand how. So instead of X-X from 0 to 5, it will go from 0% to 100% (but the code below to keep the tick points appropriately. Thanks!

  from matplotlib import Empel_tolakits.pex_grid.exlslines import subplot data by PPT as pipette = [8,12,15,17,18,18.5] fig = PLTFiguer (1, (7,4)) ax = subplot (fig, 111) Fig: The code below gives you the code below: AadA_Spllot (ax) plt.plot (data)    

itemprop = "text">

S Leaked X percentages, which are based on percentages, assume that the spaces in each of your values ​​are 0% and 100%.

This creates an perc array Creates an equal-distance percentage, it can be used to plot it, after which the formatting of the X-axis is adjusted so that the percent mark can be used in. Unfortunately, this old-style String Using the formatting, as opposed to the new style, old style docs can be seen.

  import matplotlib.pyplot as plp import nppy as NP import matplotlib.ticker form In mtick data = [8,12,1 5,17,18,18.5] perc = np.linspace (0, 100, lane (data)) fig = plt.figure (1, (7,4)) ax = fig .add_subplot (1,1,1) ax.plot (Perc, data) fmt = '% .0f %%' # format You want to tick, eg '40%' xticks = mtick.FormatStrFormatter (FMT) ax.xaxis .set_major_formatter (xticks) plt.show ()   

example plot < / P>

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -