title: Making Load Duration Curves in Matplotlib
body: <p>I'm trying to plot a load duration curve in matplotlib. A load duration curve is basically a sorted list of numbers from high to low on the y axis and an index which usually represents time in hours. I am having trouble plotting the numbers from high to low. Matplotlib is plotting them from low to high even though I have sorted the list. My code is below:</p>
  
  <pre><code>meter_data = data_dictionary[key]
  loading = get_loading_curve(key,time_series,meter_data)
  loading.sort(reverse=True)
  percent_loading = 100*numpy.array(loading)
  meter_data.sort(reverse=True)
  meter_data = numpy.array(meter_data)
  print meter_data
  l = len(meter_data)
  index = numpy.array(range(0,l))
  </code></pre>
  
  <p>I'm trying to plot meter_data on the y axis and index on the x axis. meter_data should be sorted high to low, so the high values should show up on the left side of the graph and descend. The print statement in the above code shows an numpy array that has the highest values first.</p>
  
  <p>I then go to plot this:</p>
  
  <pre><code>ax = fig.add_subplot(2,2,1)
  plt.plot(index,meter_data)
  plt.title('Hours vs. Load',size = 14,color = 'g')
  plt.xlabel('Hours',size = 12)
  plt.ylabel('MVA',size = 12)
  plt.grid(b = True,which = 'major',color ='k',linestyle = '-')
  plt.minorticks_on()
  plt.grid(b = True,which = 'minor',axis = 'y',color ='r',linestyle = ':')
  </code></pre>
  
  <p>But I end up getting the plot in reverse, it plots it from low to high not high to low. I'll see if I can get a photo up later, for some reason, I'm not able to post photos. It should look like this: </p>
  
  <p><a href="https://en.wikipedia.org/wiki/Load_duration_curve" rel="nofollow">https://en.wikipedia.org/wiki/Load_duration_curve</a></p>
  
  <p>I had this code near the top of my script</p>
  
  <pre><code>path = ' '
  os.chdir(path)
  </code></pre>
  
  <p>I changed the path to move where PDF outputted. Before I added this code:</p>
  
  <pre><code>loading = get_loading_curve(key,time_series,meter_data)
  loading.sort(reverse=True)
  </code></pre>