Data Visualization
Using Matplotlib
Matplotlib is a powerful data visualization tool, and one of the most widely used in Python.
IPython is an enhanced Python shell with more powerful debugging, inputs and outputs and more.
Pyplot is the interface for matplotlib
Simple Plot
Given a simple sine and cosine plot, matplotlib allows the user to control the figure size and dpi, line width, color and style, axes, axis and grid properties, text and font properties and more of the given visual graph.
-
Changing colors: Change the colors by setting the ‘color’ variable of the specific set of data to whatever color you would prefer
-
Setting limits: Set the limits of the graph by setting the ‘min’ and ‘max’ variables of the graph to whatever you would like the minimum and maximum bounds of the graph to be.
-
Ticks:Set the ticks of the graph axis by giving setting the .xtick and .ytick to the set of values that you would like displayed on the axis
-
Legend: To create a legend for the graph, set the display for the data as you wish (how the line looks, the labels that you want displayed for each kind of data, the style in which that data is displayed), and then create the .legend() function, and feed in the area that you would like it displayed and whether you would like it to have a border
Figures
Figures are the windows where the GUI has ‘Figure #’ in the title. The numbering starts at 1 rather than 0 which is conventional in Python.
Subplots
Subplots can be used to display multiple plots in on a multi-axes grid system. You need to specify the number of rows and columns when choosing the way to display your subplots.
Axes
Axes are similar to subplots but they allow placement of plots anywhere in the figure. If you wanted to put a small plot inside of a bigger plot, you would use axes.
Things I want to know more about
- The layout of subplots seems a little confusing for me. I think that it might be similar to a CSS concept that i cannot remember for the life of me, but the layout is ringing a bell somewhere in my memory of CSS. As it stands now though, I don’t really understand the concept.