I have this dataframe:
pd.DataFrame({'Depth': {0: 0.2,
1: 0.4,
2: 0.4,
3: 0.4,
4: 0.4,
5: 0.4,
6: 0.6000000000000001,
7: 0.4,
8: 3.2,
9: 2.0},
'DateTimeUTC': {0: Timestamp('2018-03-28 06:25:08'),
1: Timestamp('2018-03-28 06:25:49'),
2: Timestamp('2018-03-28 06:27:06'),
3: Timestamp('2018-03-28 06:32:11'),
4: Timestamp('2018-03-28 06:32:59'),
5: Timestamp('2018-03-28 06:34:02'),
6: Timestamp('2018-03-28 06:35:38'),
7: Timestamp('2018-03-28 06:37:04'),
8: Timestamp('2018-03-28 06:39:08'),
9: Timestamp('2018-03-28 06:40:52')}})
which looks like this:
<table>
<tr><th></th><th>Depth</th><th>DateTimeUTC</th></tr>
<tr><th>0</th><td>0.2</td><td>2018-03-28 06:25:08</td></tr>
<tr><th>1</th><td>0.4</td><td>2018-03-28 06:25:49</td></tr>
<tr><th>2</th><td>0.4</td><td>2018-03-28 06:27:06</td></tr>
<tr><th>3</th><td>0.4</td><td>2018-03-28 06:32:11</td></tr>
<tr><th>4</th><td>0.4</td><td>2018-03-28 06:32:59</td></tr>
<tr><th>5</th><td>0.4</td><td>2018-03-28 06:34:02</td></tr>
<tr><th>6</th><td>0.6</td><td>2018-03-28 06:35:38</td></tr>
<tr><th>7</th><td>0.4</td><td>2018-03-28 06:37:04</td></tr>
<tr><th>8</th><td>3.2</td><td>2018-03-28 06:39:08</td></tr>
<tr><th>9</th><td>2.0</td><td>2018-03-28 06:40:52</td></tr>
</table>
Note the all DateTimeUTC
are within 2018. When I try to plot depth vs time using sns.scatterplot I get:
sns.scatterplot('DateTimeUTC', 'Depth', data=df)
Why does the X-axis start at year 2000? Am I doing something wrong?
Size can be set by passing value to the “s” parameter. The parameter “s” is a matplotlib parameter. The “s” will be treated as **kwargs when you pass it in seaborn. Default value of s is 36. You can increase or decrease this number to get bigger or smaller markers respectively.
In Seaborn's scatterplot() function, we can change the shape of markers by a variable using style argument. In this example, we have changed the marker's shape based on the value of the variable, “sex” in the dataframe. Notice that data points corresponding to males are different from females.
scatterplot() function. We will only use the x, y parameters of the function.
A scatter plot displays data between two continuous data. It shows how one data variable affects the other variable. A scatter plot can display data in different types of plots, both 2D and 3D. Seaborn is a widely-used library in Python for data visualization.
I posted the question as an issue on Github, and got this great response. Basically, the problem is that plt.scatter
does not deal with dates well, and seaborn uses it. If seaborn will add a type check for the x-axis, which uses plt.plot_date
for date values instead, this will be fixed. In the meanwhile, one can create a custom version of sns.scatterplot
that does excatly that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With