Products > Programming

matplotlib charts and syntax from Python

(1/1)

RoGeorge:
Each time I plot something from matplotlib/Python I find myself googling for syntax and how to do stupid but necessary things, like adding an extra axis, or changing the ticks color, or making the grid dashed, etc.

Sometimes I spend hours trying various copy/pasted pieces of code to configure a single chart.  Only certain combinations works, and so far I couldn't deduce what are the rules, the syntax, or the structure and attributes of a chart.

Random example:  to make y axis logarithmic it's either with plt.yscale('log) or ax.set_yscale(log) like in the multiline comented section.

--- Code: ---import matplotlib.pyplot as plt

# data processing here ... then plot

plt.plot(frequency, V1, 'red')

#plt.yscale('log',base=2)
plt.yscale('log')


'''
# alternative method
fig = plt.figure()
#ax = fig.add_subplot(2, 1, 1)
ax = fig.add_subplot()

plt.plot(frequency, V1, 'red')

ax.set_yscale('log')
'''


#plt.xlim((400*1e3, 600*1e3))
#plt.ylim((0.2, 0.3))

plt.grid()
plt.show()
--- End code ---

Where can I find a systematic way to learn about how to configure charts and plots?
Is there a map with all the objects, their hierarchy, methods, attributes and enumerations that are valid?

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod