You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

261 lines
10 KiB

4 years ago
  1. """
  2. This is a procedural interface to the matplotlib object-oriented
  3. plotting library.
  4. The following plotting commands are provided; the majority have
  5. MATLAB |reg| [*]_ analogs and similar arguments.
  6. .. |reg| unicode:: 0xAE
  7. _Plotting commands
  8. acorr - plot the autocorrelation function
  9. annotate - annotate something in the figure
  10. arrow - add an arrow to the axes
  11. axes - Create a new axes
  12. axhline - draw a horizontal line across axes
  13. axvline - draw a vertical line across axes
  14. axhspan - draw a horizontal bar across axes
  15. axvspan - draw a vertical bar across axes
  16. axis - Set or return the current axis limits
  17. autoscale - turn axis autoscaling on or off, and apply it
  18. bar - make a bar chart
  19. barh - a horizontal bar chart
  20. broken_barh - a set of horizontal bars with gaps
  21. box - set the axes frame on/off state
  22. boxplot - make a box and whisker plot
  23. violinplot - make a violin plot
  24. cla - clear current axes
  25. clabel - label a contour plot
  26. clf - clear a figure window
  27. clim - adjust the color limits of the current image
  28. close - close a figure window
  29. colorbar - add a colorbar to the current figure
  30. cohere - make a plot of coherence
  31. contour - make a contour plot
  32. contourf - make a filled contour plot
  33. csd - make a plot of cross spectral density
  34. delaxes - delete an axes from the current figure
  35. draw - Force a redraw of the current figure
  36. errorbar - make an errorbar graph
  37. figlegend - make legend on the figure rather than the axes
  38. figimage - make a figure image
  39. figtext - add text in figure coords
  40. figure - create or change active figure
  41. fill - make filled polygons
  42. findobj - recursively find all objects matching some criteria
  43. gca - return the current axes
  44. gcf - return the current figure
  45. gci - get the current image, or None
  46. getp - get a graphics property
  47. grid - set whether gridding is on
  48. hist - make a histogram
  49. ioff - turn interaction mode off
  50. ion - turn interaction mode on
  51. isinteractive - return True if interaction mode is on
  52. imread - load image file into array
  53. imsave - save array as an image file
  54. imshow - plot image data
  55. legend - make an axes legend
  56. locator_params - adjust parameters used in locating axis ticks
  57. loglog - a log log plot
  58. matshow - display a matrix in a new figure preserving aspect
  59. margins - set margins used in autoscaling
  60. pause - pause for a specified interval
  61. pcolor - make a pseudocolor plot
  62. pcolormesh - make a pseudocolor plot using a quadrilateral mesh
  63. pie - make a pie chart
  64. plot - make a line plot
  65. plot_date - plot dates
  66. plotfile - plot column data from an ASCII tab/space/comma delimited file
  67. pie - pie charts
  68. polar - make a polar plot on a PolarAxes
  69. psd - make a plot of power spectral density
  70. quiver - make a direction field (arrows) plot
  71. rc - control the default params
  72. rgrids - customize the radial grids and labels for polar
  73. savefig - save the current figure
  74. scatter - make a scatter plot
  75. setp - set a graphics property
  76. semilogx - log x axis
  77. semilogy - log y axis
  78. show - show the figures
  79. specgram - a spectrogram plot
  80. spy - plot sparsity pattern using markers or image
  81. stem - make a stem plot
  82. subplot - make one subplot (numrows, numcols, axesnum)
  83. subplots - make a figure with a set of (numrows, numcols) subplots
  84. subplots_adjust - change the params controlling the subplot positions of current figure
  85. subplot_tool - launch the subplot configuration tool
  86. suptitle - add a figure title
  87. table - add a table to the plot
  88. text - add some text at location x,y to the current axes
  89. thetagrids - customize the radial theta grids and labels for polar
  90. tick_params - control the appearance of ticks and tick labels
  91. ticklabel_format - control the format of tick labels
  92. title - add a title to the current axes
  93. tricontour - make a contour plot on a triangular grid
  94. tricontourf - make a filled contour plot on a triangular grid
  95. tripcolor - make a pseudocolor plot on a triangular grid
  96. triplot - plot a triangular grid
  97. xcorr - plot the autocorrelation function of x and y
  98. xlim - set/get the xlimits
  99. ylim - set/get the ylimits
  100. xticks - set/get the xticks
  101. yticks - set/get the yticks
  102. xlabel - add an xlabel to the current axes
  103. ylabel - add a ylabel to the current axes
  104. autumn - set the default colormap to autumn
  105. bone - set the default colormap to bone
  106. cool - set the default colormap to cool
  107. copper - set the default colormap to copper
  108. flag - set the default colormap to flag
  109. gray - set the default colormap to gray
  110. hot - set the default colormap to hot
  111. hsv - set the default colormap to hsv
  112. jet - set the default colormap to jet
  113. pink - set the default colormap to pink
  114. prism - set the default colormap to prism
  115. spring - set the default colormap to spring
  116. summer - set the default colormap to summer
  117. winter - set the default colormap to winter
  118. _Event handling
  119. connect - register an event handler
  120. disconnect - remove a connected event handler
  121. _Matrix commands
  122. cumprod - the cumulative product along a dimension
  123. cumsum - the cumulative sum along a dimension
  124. detrend - remove the mean or besdt fit line from an array
  125. diag - the k-th diagonal of matrix
  126. diff - the n-th difference of an array
  127. eig - the eigenvalues and eigen vectors of v
  128. eye - a matrix where the k-th diagonal is ones, else zero
  129. find - return the indices where a condition is nonzero
  130. fliplr - flip the rows of a matrix up/down
  131. flipud - flip the columns of a matrix left/right
  132. linspace - a linear spaced vector of N values from min to max inclusive
  133. logspace - a log spaced vector of N values from min to max inclusive
  134. meshgrid - repeat x and y to make regular matrices
  135. ones - an array of ones
  136. rand - an array from the uniform distribution [0,1]
  137. randn - an array from the normal distribution
  138. rot90 - rotate matrix k*90 degress counterclockwise
  139. squeeze - squeeze an array removing any dimensions of length 1
  140. tri - a triangular matrix
  141. tril - a lower triangular matrix
  142. triu - an upper triangular matrix
  143. vander - the Vandermonde matrix of vector x
  144. svd - singular value decomposition
  145. zeros - a matrix of zeros
  146. _Probability
  147. normpdf - The Gaussian probability density function
  148. rand - random numbers from the uniform distribution
  149. randn - random numbers from the normal distribution
  150. _Statistics
  151. amax - the maximum along dimension m
  152. amin - the minimum along dimension m
  153. corrcoef - correlation coefficient
  154. cov - covariance matrix
  155. mean - the mean along dimension m
  156. median - the median along dimension m
  157. norm - the norm of vector x
  158. prod - the product along dimension m
  159. ptp - the max-min along dimension m
  160. std - the standard deviation along dimension m
  161. asum - the sum along dimension m
  162. ksdensity - the kernel density estimate
  163. _Time series analysis
  164. bartlett - M-point Bartlett window
  165. blackman - M-point Blackman window
  166. cohere - the coherence using average periodiogram
  167. csd - the cross spectral density using average periodiogram
  168. fft - the fast Fourier transform of vector x
  169. hamming - M-point Hamming window
  170. hanning - M-point Hanning window
  171. hist - compute the histogram of x
  172. kaiser - M length Kaiser window
  173. psd - the power spectral density using average periodiogram
  174. sinc - the sinc function of array x
  175. _Dates
  176. date2num - convert python datetimes to numeric representation
  177. drange - create an array of numbers for date plots
  178. num2date - convert numeric type (float days since 0001) to datetime
  179. _Other
  180. angle - the angle of a complex array
  181. griddata - interpolate irregularly distributed data to a regular grid
  182. load - Deprecated--please use loadtxt.
  183. loadtxt - load ASCII data into array.
  184. polyfit - fit x, y to an n-th order polynomial
  185. polyval - evaluate an n-th order polynomial
  186. roots - the roots of the polynomial coefficients in p
  187. save - Deprecated--please use savetxt.
  188. savetxt - save an array to an ASCII file.
  189. trapz - trapezoidal integration
  190. __end
  191. .. [*] MATLAB is a registered trademark of The MathWorks, Inc.
  192. """
  193. from matplotlib.cbook import flatten, silent_list, iterable, dedent
  194. import matplotlib as mpl
  195. from matplotlib.dates import (
  196. date2num, num2date, datestr2num, strpdate2num, drange, epoch2num,
  197. num2epoch, mx2num, DateFormatter, IndexDateFormatter, DateLocator,
  198. RRuleLocator, YearLocator, MonthLocator, WeekdayLocator, DayLocator,
  199. HourLocator, MinuteLocator, SecondLocator, rrule, MO, TU, WE, TH, FR,
  200. SA, SU, YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY,
  201. relativedelta)
  202. # bring all the symbols in so folks can import them from
  203. # pylab in one fell swoop
  204. ## We are still importing too many things from mlab; more cleanup is needed.
  205. from matplotlib.mlab import (
  206. amap, base_repr, binary_repr, bivariate_normal, center_matrix, csv2rec,
  207. demean, detrend, detrend_linear, detrend_mean, detrend_none, dist,
  208. dist_point_to_segment, distances_along_curve, entropy, exp_safe,
  209. fftsurr, find, frange, get_sparse_matrix, get_xyz_where, griddata,
  210. identity, inside_poly, is_closed_polygon, ispower2, isvector, l1norm,
  211. l2norm, log2, longest_contiguous_ones, longest_ones, movavg, norm_flat,
  212. normpdf, path_length, poly_below, poly_between, prctile, prctile_rank,
  213. rec2csv, rec_append_fields, rec_drop_fields, rec_join, rk4, rms_flat,
  214. segments_intersect, slopes, stineman_interp, vector_lengths,
  215. window_hanning, window_none)
  216. from matplotlib import cbook, mlab, pyplot as plt
  217. from matplotlib.pyplot import *
  218. from numpy import *
  219. from numpy.fft import *
  220. from numpy.random import *
  221. from numpy.linalg import *
  222. import numpy as np
  223. import numpy.ma as ma
  224. # don't let numpy's datetime hide stdlib
  225. import datetime
  226. # This is needed, or bytes will be numpy.random.bytes from
  227. # "from numpy.random import *" above
  228. bytes = __import__("builtins").bytes