![]() For most of them, if you want markers with area 5, you write s=5. The other matplotlib functions do not define marker size in this way. This means that if we want a marker to have area 5, we must write s=5**2. In plt.scatter(), the default marker size is s=72. The s keyword argument controls the size of markers in plt.scatter(). We can fix this by changing the marker size. ![]() It’s hard to see the relationship in the $10-$30 total bill range. This looks nice but the markers are quite large. To save space, we won’t include the label or title code from now on, but make sure you do. Let’s add some axis labels and a title to make our scatter plot easier to understand. They tell us more about the plot and is it essential you include them on every plot you make. So we should try and get our customers to spend as much as possible. This means that as the bill increases, so does the tip. Nice! It looks like there is a positive correlation between a total_bill and tip. A scatter graph shows what happens to the dependent variable ( y) when we change the independent variable ( x). We call the former the independent variable and the latter the dependent variable. First, we pass the x-axis variable, then the y-axis one. It’s very easy to do in matplotlib – use the plt.scatter() function. Let’s make a scatter plot of total_bill against tip. The variables total_bill and tip are both NumPy arrays. Don’t worry if you don’t understand what this is just yet. The variable tips_df is a pandas DataFrame. Total_bill = tips_df.total_bill.to_numpy() # Seaborn's default settings look much nicer than matplotlib
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |