'When plotting from a CSV file using matplotlib, 0 values on X, Y axis are not plotting and I need them to be plotted
The 0 values from my CSV file are not plotting, any idea as to why this is happening and how I can ensure they are plotted?
import pandas as pd
import numpy as np from matplotlib
import pyplot as plt
columns = np.array(["Ast", "Gls"])
df = pd.read_csv(r"document.csv", usecols=columns)
print("Contents in csv file:\n", df)
colors =(["red"])
size = ([500])
plt.scatter(df.Ast, df.Gls, c=colors, s=size, alpha=0.5, cmap='viridis')
plt.show()
Contents in csv file:
Gls Ast
0 2 1
1 4 5
2 0 3
3 1 9
4 1 1
5 4 2
6 1 1
7 5 4
8 7 4
9 4 1
10 5 6
11 4 1
12 0 1
13 2 2
14 3 0
15 1 0
16 0 2
17 4 5
18 0 1
19 4 3
20 2 5
21 14 11
22 4 1
23 3 6
24 7 1
25 2 5
26 9 3
For example all the results with figures above zero are plotted.
Solution 1:[1]
This is the plot I'm getting with your code and data:
You can clearly see that all points are accounted for, even the ones in which X or Y is zero.
There are a few points having a darker red color: it means that there are 2 or more points sharing the same location.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Davide_sd |

