# Plot Graph to Show Ideas - Installation and Scatter Plot

When we do experiments to observe or demonstrate some ideas, one graph can produce a correct intuition if you use a proper graph. For example, if you want to observe the distribution of data, the bar or line graphs are not sufficient to show this information. Because they can only show the average and variance of data. If the data is plotted by the violin or CDF (cumulative distribution function), they will show the distribution of data in a better way.

Of course, how to visualize data is not easy work and I’m not a profession here. I just want to introduce 1) how to plot some general graphs by Python3 (Matplotlib package); 2) these graphs are suited to which situations.

If you know better references, please feel free to send them to me by Email. (zurielibra@gmail.com)

More examples of data visualization can be found on the website of Matplotlib.

# Install Matplotlib

The installation instruction can be found on the website of Matplotlib. If you have pip, you can use the following command to install directly.

# Scatter Plot (2D)

A comprehensive description of the scatter plot can be found on Wikipedia.

TL;DR: the scatter plot is usually used to find the distribution of data with two dimensions.

To draw the scatter plot, we can use the code shown below.

You can just copy line 7 to plot data.

In the function plt.scatter(), only the first two variables are necessary. If you want to beauty your graph, you can play with marker,color, etc. If you plot several datasets on one graph, you may want to use label and plt.legend() to distinguish these datasets.

To make your graph readable, lables for x-axis and y-axis are necessary. You can set them by plt.xlabel() and plt.ylabel() easily. The title of graph can also help reader to understand graph, so you can set it by plt.title(). However, title should not be plot if this graph is used in academic publications.

To make your graph readable, labels for the x-axis and y-axis are necessary. You can set them by plt.xlabel() and plt.ylabel() easily. The title of the graph can also help the reader to understand the graph, so you can set it by plt.title(). However, the title should not be plot if this graph is used in academic publications.

After all of the code for configuration, you only need plt.show() to present the final graph. You can also use plt.savefig() to save the graph into any format (pdf, png, jpg, etc.).