#๐Ÿ”’ Scatter plot date overlapping

68 messages ยท Page 1 of 1 (latest)

crystal nightBOT
#

@sage sundial

Python help channel opened

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.

sage sundial
#

hi

#

this is the error look at the date

turbid sierra
#

!paste your code please

crystal nightBOT
#
Pasting large amounts of code

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.

restive aurora
#

take a look at set_xticks function in matplotlib

sage sundial
#

i have 0 knowledge in python

#

i dont know what that means

#

i already paste the code

next flume
#

You didn't give us the URL to the pastebin.

sage sundial
#

im sorry

sage sundial
#

in*

restive aurora
#

the problem here is that you have too many points and matplotlib tries to render all the labels

turbid sierra
#

So is this your code? What's the issue?

sage sundial
#

the issue is the date

restive aurora
#

so you gotta limit the x axis labels to something like months or only years

sage sundial
sage sundial
#

because i have no idea on how to do that

restive aurora
#

or well you're using pandas, so why not try data_1.plot(), pandas should handle the labels better for you

turbid sierra
#

!rule homework

crystal nightBOT
#

8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.

turbid sierra
#

We won't do this for you, but we can help you write it yourself.

sage sundial
#

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

restive aurora
#

try

data_1.plot(x='date', y='tank')

see what comes out

sage sundial
#

where do i put it ?

#

which line

restive aurora
#

right after you load the dataframe

sullen phoenix
# sage sundial

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).

sage sundial
#

works but it doesn't look like a scatter plot anymore

restive aurora
#

try data_1.plot(kind="scatter", x='date', y='tank')

sage sundial
#

and there are now 2

#

2 tank plots

#

charts*

restive aurora
#

yeah

#

if you didn't remove the original one, there will be two of course

sage sundial
#

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?

sage sundial
sage sundial
#

my imports are : import pandas as pd
import matplotlib.pyplot as plt

#

any help ?

sullen phoenix
#

what's data_1['date'].dtype?

sage sundial
#

what do you mean

#

i dont even know

sullen phoenix
#

well, check

sage sundial
#

Sir

#

you mean the file?

#

its a .csv file

#

containing the data for the chart

sullen phoenix
#

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)

sage sundial
#

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

crystal nightBOT
#
Python help channel closed

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.