From the course: Python Data Visualization: Create Impactful Visuals, Animations, and Dashboards by Pearson

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Demo, part 1

Demo, part 1

As before, I'm importing all the packages and modules that I'm going to be using right at the beginning. Of course, here, the star of the show is Matplotlib, so I start by importing that. Of course, also pandas and NumPy, because they'll come in handy. And as part of matplotlib, I'm also importing a few of the sub-modules that it And that gives us a red line. Everything remains the same. just the color gets changed to red. We can also add a legend. So here we're starting with plt.plot x and y in red, and then adding a legend. For the legend, you have to provide a list of strings that you want to use for the legend. Here, because we're only plotting one thing, our list only has one value, and in this case, I'm using sin function as my legend. MantlotLib automatically decides where the legend box should be placed. The default usually is the top right-hand corner, but if there's things plotted on that corner, it might end up on one of the other corners. If you call plt.plot multiple…

Contents