forked from cs573-22s/a2-DataVis-5ways
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyCode(matplotlib).py
More file actions
34 lines (27 loc) · 992 Bytes
/
pyCode(matplotlib).py
File metadata and controls
34 lines (27 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.scatter.html
# https://matplotlib.org/stable/gallery/shapes_and_collections/scatter.html#sphx-glr-gallery-shapes-and-collections-scatter-py
# https://kanoki.org/2020/08/30/matplotlib-scatter-plot-color-by-category-in-python/
# https://seaborn.pydata.org/tutorial/color_palettes.html
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
plt.figure(figsize=(10, 10), dpi=100)
file = pd.read_csv("cars-sample.csv")
plotpic = sns.scatterplot(
x = "Weight",
y = "MPG",
size = "Weight",
hue = "Manufacturer",
marker = '^',
palette = "colorblind",
data = file,
alpha = 0.5,
sizes = (20, 100)
)
# change ticks from intervals of 5 to interval of 10 for y axis
plt.yticks([10,20,30,40])
plt.ylabel("MPG", fontsize=16)
# change ticks from intervals of 500 to interval of 1000 for x axis
plt.xticks([2000,3000,4000,5000])
plt.xlabel("Weight", fontsize=16)
print(plotpic)