![]() ![]() Idea is to compare sales of products and how they performed in the last 5 years. In the code below, we are creating a pandas DataFrame consisting sales of two products A and B along with time period (Year). Legend=False tells pandas to turnoff legendĪdd Multiple Lines in Line Graph Pandas Way Syntax of ax.set family functions is equivalent to plt. It can also be written like the code below. set method is used to add x and y axis labels, limits and ticks. In addition to these basic options, the errorbar function has many options to fine-tune the. You can mention any color ('g' for green, 'b' for blue, 'k' for black etc.) plot, outlined in Simple Line Plots and Simple Scatter Plots. They refer to cirles, dash lines, dash-dotted lines. You can also use these styles ro, ro-, r+, rD. ![]() Plt.bar(x, y, color='red') # Change bar color Plt.ylabel("Math Score") # Assign the name of the y axis To do this, we can create a fake data series that shows the minimum and maximum value along the x-axis (0 and 20) as well as two y-values that are both equal to 20: Next, right click anywhere on the chart and click Select Data. Plt.xlabel('Students') # Assign the name of the x axis Now suppose we would like to add a horizontal line at y 20. Plt.title("Simple Bar graph") # Name title of the graph Suppose you want to show comparison between cities in terms of average annual income. plt.hline: draws a horizontal line at a specified level plt.vline: draws a vertical. The following tables explain different graphs along with functions defined for these graphs in matplotlib library.īar Graph is used to make comparison between different categories or groups. Create marks using pyplot functions like plot, bar, scatter etc. If you are using Jupyter Notebook, you can submit this command %matplotlib inline once to display or show plots automatically without need to enter plt.show() after generation of each plot.įunctions used for different types of plots ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |