#๐ Scatter plot date overlapping
68 messages ยท Page 1 of 1 (latest)
@sage sundial
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
!paste your code please
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
take a look at set_xticks function in matplotlib
i have 0 knowledge in python
i dont know what that means
i already paste the code
You didn't give us the URL to the pastebin.
there is no set_xticks on the code
in*
the problem here is that you have too many points and matplotlib tries to render all the labels
So is this your code? What's the issue?
the issue is the date
so you gotta limit the x axis labels to something like months or only years
this is the issue
can you please modify the code for me?
because i have no idea on how to do that
or well you're using pandas, so why not try data_1.plot(), pandas should handle the labels better for you
!rule homework
8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.
We won't do this for you, but we can help you write it yourself.
sure that's not a problem
this is an MPU subject
meaning it's like a side subject. this isnt main subject and my major isnt in coding
So how do we get started
I appreciate yall trying to help
try
data_1.plot(x='date', y='tank')
see what comes out
right after you load the dataframe
most times I've seen this, the reason was that the date column is actually a column of strings (in which case matplotlib shows all the labels rather than just some).
using the code you gave,
works but it doesn't look like a scatter plot anymore
try data_1.plot(kind="scatter", x='date', y='tank')
You're meant to say "data_1.plot(x='date', y='tank')" this alone reads the data and creates a scatter plot and creates date?
now it looks like scatter plot but the problem is back
anyway to restrict that?
my imports are : import pandas as pd
import matplotlib.pyplot as plt
any help ?
what's data_1['date'].dtype?
well, check
You read that csv file into a pandas dataframe, data_1. Each column of a dataframe has a data type ("dtype"), and the behaviour may depend on it significantly. Check what dtype that column is.
(as in, just print data_1['date'].dtype, or print data_1.dtypes and look up that entry)
nah its alright
i figured it out
the date was overlapping because there was too much data on the file and the output were overlapped from it
I replaced the date with index
looks much more presentable now
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.