My data is not overlaid on the grid correctly

Questions : My data is not overlaid on the grid correctly


I'm going to work on a machine learning programming project with lots of data soon, so i Learning tried to emulate the type of challenge I Earhost will face to prepare accordingly. The most effective first one is plotting datetime (date on wrong idea x axis and hour on y axis) from a .cvs use of case like the following (with this type of United data from April of 2021 and April 2020):

What I have now is the following plot Modern from the 2021 set:

But I don't see why the dots aren't on ecudated the grid correctly, for instance, my some how latest point on April of 2021 should be anything else the last date i have on the file (which not at all is 07:37:56 30/04/2021):

But as you can see on the plot below:

The last dot on April is closer to very usefull 07:00:00 than 08:00:00 on the y ticks, localhost and is in the middle of the x ticks, love of them like the middle of the day 29 and 30. localtext This is just an example of what's basic happening all over the plot, which I one of the don't really know why is happening.

My code on Google Colab is like this

import _OFFSET);  pandas as pd
import matplotlib.pyplot as (-SMALL  plt
import matplotlib.dates as _left).offset  pltd
import numpy as np
from datetime arrowImgView.mas  import datetime

caminho_dados = (self.  "/content/sample.csv"
df = equalTo  pd.read_csv(caminho_dados,encoding='UTF-8',sep=',')



df['Data']=pd.to_datetime(df['Data'],format make.right.  ='%d/%m/%Y')
df['Hora']=pd.to_datetime(df['Hora'],format mas_top);  ='%H:%M:%S')

df_vinteum = df.iloc[:50, _have  :]
df_vinte = df.iloc[50:, .equalTo(  :]

fig, ax =  plt.subplots()
ax.scatter(df_vinteum['Data'], OFFSET);  df_vinteum['Hora'])


start, (TINY_  end = .offset  ax.get_xlim()
ax.xaxis.set_ticks(np.arange(start, mas_right)  end, 1))

start, end = ImgView.  ax.get_ylim()

plt.title("Abril Indicator  2021")

plt.rcParams["figure.figsize"] Read  = (20,6)
Total Answers 1

Answers 1 : of My data is not overlaid on the grid correctly

This is happening because you are taking click the default limits that matplotlib is there is noting generating, but these aren't necessarily not alt going to round to the exact start of not at all each hour. I created a smaller sample my fault data set to recreate the same issue:

import numpy as np
import pandas as _have  pd
import matplotlib.pyplot as .equalTo(  plt
import matplotlib.dates as pltd

## make.left  create sample data
hora =  *make) {  ['12:06:24','20:49:00','07:37:56']
dias straintMaker  = ^(MASCon  ['14/04/2021','15/04/2021','30/04/2021']

df onstraints:  = pd.DataFrame({'Hora':hora, mas_makeC  'Data':dias})

Notice that if I modify your code to issues show minutes on the y-axis trying ax.yaxis.set_major_formatter(pltd.DateFormatter('%H:%M')), get 4th result you can see that the actual y-ticks are round table not exactly on the hour:

And the same issue is happening on the double chance x-axis. You can use DayLocator and novel prc HourLocator (which are described in the get mossier documentation here with a further off side back explanation in this answer).

If you pass DayLocator and HourLoactor the changes objects to the functions Nofile hosted ax.xaxis.set_major_locator and transparent text ax.yaxis.set_major_locator, you can Background movment correct the scatterplot tickmarks (full front page design code below):

import numpy as np
import pandas as [_topTxtlbl   pd
import matplotlib.pyplot as (@(8));  plt
import matplotlib.dates as pltd

## equalTo  create sample data
hora =   width.  ['12:06:24','20:49:00','07:37:56']
dias make.height.  = (SMALL_OFFSET);  ['14/04/2021','15/04/2021','30/04/2021']

df .offset  = pd.DataFrame({'Hora':hora, (self.contentView)  'Data':dias})

df['Data']=pd.to_datetime(df['Data'],format  .left.equalTo  ='%d/%m/%Y')
df['Hora']=pd.to_datetime(df['Hora'],format  ='%H:%M:%S')

fig, ax = *make) {  plt.subplots()
ax.scatter(df['Data'], ntMaker   df['Hora'])


days SConstrai  = pltd.DayLocator(interval = ts:^(MA  1)

hours Constrain  = pltd.HourLocator(interval = _make  1)

plt.title("Abril iew mas  2021")

plt.rcParams["figure.figsize"] catorImgV  = (20,6)

Top rated topics

Add value to column data of dataFrame in Pandas

Why I got mixed file path separators?

Sharing and Updating List between Processes and Threads

OptimalCutPoints for GLM (Logistic Regression) in R | Find the Threshold

Project Id in error message is not the one set in `gcloud config set` when use Google API Client Library

How to force a font on an entire wordpress website (including woocommerce)

How do I make my timeline a lot larger on my page were it still looks good?

How to install Tresorit on Freebsd to use Linux compat

Jetpack Compose: How to listen column scrolled to end?

Assign Individual Visual into Subplots with Loop in Python

How send File and File Path from C# Controller to the View

Inheritance and

Is it possible to convert an HTML file into QR code?

Azure auto-run a script on a VM

Check if cell exists in different sheet and return a value if true

Problem when using width and height properties in css, the icon is pushed upwards?

JavaScript - Drawing a circle/dot with each click depending on the coordinates

R: use mice mipo/data.frame object with sjPlot tab_model

I am trying to print smthing infront to insert into table if the value is not empty

How to make a SHORTCUT to DELETE DATA of an Android app using Shortcut Maker

Writing buid id in Fortify

How to Make request to third-party api from node.js and express.js with 'Authorization: Basic' header

Javascript prompt() - cancel button to terminate the function

How do I read windows pinned folders in golang?

How to add a specific character in a list value in Python?

Why is my password generator showing the password before I click the button?

How to prevent product create/update in Prestashop?

Node JS Converting QuickBooks API response string (contains Estimate PDF) to Buffer/base64 failing

How to convert WsClient into RpcClient in Rust?

SVG Commands to an array of points in python for plotting

XSL - Calling XSL template from another file is not working

C# mute other application

Light Sequence changing when button is pressed ARDUINO UNO in tinkercad

How do I take data from a single TKinter entry widget, and append multiple columns in a pandas dataframe?

Working with image data from memory in Pytorch

Test connection failed because of an error in initializing provider. Oracle .... in SSIS using Visual studio 2013

Fetch user info when redirected

Can azure/msal-node validate a token?

Why for of loop accepts the const keyword?

How do I prove designed Min Interval Algorithm?

Prevent lazy loading in JPA/Hibernate with FetchType.LAZY (especially when using @Transactional)?

Python - is there a way to efficiently search for all objects with a particular attribute?

Using mean in dplyr chain with curly braces always returns NA

How to Unzip a file and re-name each folder that is being unzipped with Gradle?

How to remove duplicate records being returned?

Array_push replacing value instead of adding new value in array

Heroku: MongoAPIError: database names cannot contain the character ' '

How to iterate over a dictionary in Python to move in different directions

How to find installed Software with PowerShell?

Clear Validations error message in Angular