Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6653241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:14:42+00:00 2026-05-26T01:14:42+00:00

I am trying to plot hourly meteorological data coming from a meteorological station with

  • 0

I am trying to plot hourly meteorological data coming from a meteorological station with ggplot2 (it’s my first time with ggplot). I’ve managed to plot daily data but having some problem when downscaling to hourly data. Data files look like that:

FECHA H_SOLAR;DIR_M;VEL_M;TEMP_M;HR;PRECIP
01/06/14 00:50:00;314.3;1.9;14.1;68.0;-99.9
01/06/14 01:50:00;322.0;1.6;13.3;68.9;-99.9
01/06/14 02:50:00;303.5;2.1;12.3;70.9;-99.9
01/06/14 03:50:00;302.4;1.6;11.6;73.1;-99.9
01/06/14 04:50:00;306.5;1.2;10.9;76.4;-99.9
01/06/14 05:50:00;317.1;0.8;12.6;71.5;-99.9
01/06/14 06:50:00;341.8;0.0;17.1;58.8;-99.9
01/06/14 07:50:00;264.6;1.2;21.8;44.9;-99.9
01/06/14 08:50:00;253.8;2.9;24.7;32.2;-99.9
01/06/14 09:50:00;254.6;3.7;26.7;27.7;-99.9
01/06/14 10:50:00;250.7;4.3;28.3;24.9;-99.9
01/06/14 11:50:00;248.5;5.3;29.1;22.6;-99.9
01/06/14 12:50:00;242.8;4.7;30.3;20.4;-99.9
01/06/14 13:50:00;260.7;4.9;31.3;17.4;-99.9
01/06/14 14:50:00;251.8;5.1;31.9;17.1;-99.9
01/06/14 15:50:00;258.1;4.6;32.4;15.3;-99.9
01/06/14 16:50:00;254.3;5.7;32.4;14.0;-99.9
01/06/14 17:50:00;252.5;4.6;32.0;14.1;-99.9
01/06/14 18:50:00;257.4;3.8;31.1;14.9;-99.9
01/06/14 19:50:00;135.8;4.2;26.0;41.2;-99.9
01/06/14 20:50:00;126.0;1.7;23.5;48.7;-99.9
01/06/14 21:50:00;302.8;0.7;21.6;53.9;-99.9
01/06/14 22:50:00;294.2;1.1;19.3;67.4;-99.9
01/06/14 23:50:00;308.5;1.0;17.5;72.4;-99.9

I have used this R commands to plot the data:

datos=read.csv("utiel.dat",sep=";",header=T,na.strings="-99.9")

dia=as.Date(datos[,1],"%y/%m/%d")       # Crear índice dia
veloc=zoo(datos[,c("VEL_M")],dia)       

gveloc=ggplot(data=datos,aes(dia,veloc))

gveloc + geom_point(colour="blue",cex=1) + ylab("Velocidad (km/h)") + xlab("Fecha") + opts(title="Velocidad media horaria") + scale_x_date(limits = as.Date(c("2007-01-01","2007-01-31")),format = "%Y-%m-%d")

and got this monthly graph with all data from a single day in the same x coordinate (i.e. the same day as it could be expected)

Hourly wind data with ggplot2

How can I manage to read not only the day but the time so each point can be plotted in it’s own x/time coordinate? I think the problem starts before plotting but I couldn’t find how to read date as YY/MM/DD H:M:S

Thanks in advance

Solution: Just an addition to put the code has worked for me

 datos$dia=as.POSIXct(datos[,1], format="%y/%m/%d %H:%M:%S")  # Read date/time as POSIXct

 ggplot(data=datos,aes(x=dia, y=TEMP_M)) + 
   geom_point(colour="red") + 
   ylab("Temperatura (ºC)") + 
   xlab("Fecha") + 
   opts(title="Temperatura media") + 
   scale_x_datetime(limits=c(as.POSIXct('2008/02/01'), as.POSIXct('2008/02/02')) ,format =  "%Y-%m-%d")

Hope it helps someone else, thanks Andrie and G.Grothendieck

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:14:42+00:00Added an answer on May 26, 2026 at 1:14 am

    as.Date only capture the date element. To capture time, you need to use as.POSIXct:

    Recreate your data:

    zz <- tempfile()
    cat("
    FECHA H_SOLAR;DIR_M;VEL_M;TEMP_M;HR;PRECIP
    01/06/14 00:50:00;314.3;1.9;14.1;68.0;-99.9
    01/06/14 01:50:00;322.0;1.6;13.3;68.9;-99.9
    01/06/14 02:50:00;303.5;2.1;12.3;70.9;-99.9
    01/06/14 03:50:00;302.4;1.6;11.6;73.1;-99.9
    01/06/14 04:50:00;306.5;1.2;10.9;76.4;-99.9
    01/06/14 05:50:00;317.1;0.8;12.6;71.5;-99.9
    01/06/14 06:50:00;341.8;0.0;17.1;58.8;-99.9
    01/06/14 07:50:00;264.6;1.2;21.8;44.9;-99.9
    01/06/14 08:50:00;253.8;2.9;24.7;32.2;-99.9
    01/06/14 09:50:00;254.6;3.7;26.7;27.7;-99.9
    01/06/14 10:50:00;250.7;4.3;28.3;24.9;-99.9
    01/06/14 11:50:00;248.5;5.3;29.1;22.6;-99.9
    01/06/14 12:50:00;242.8;4.7;30.3;20.4;-99.9
    01/06/14 13:50:00;260.7;4.9;31.3;17.4;-99.9
    01/06/14 14:50:00;251.8;5.1;31.9;17.1;-99.9
    01/06/14 15:50:00;258.1;4.6;32.4;15.3;-99.9
    01/06/14 16:50:00;254.3;5.7;32.4;14.0;-99.9
    01/06/14 17:50:00;252.5;4.6;32.0;14.1;-99.9
    01/06/14 18:50:00;257.4;3.8;31.1;14.9;-99.9
    01/06/14 19:50:00;135.8;4.2;26.0;41.2;-99.9
    01/06/14 20:50:00;126.0;1.7;23.5;48.7;-99.9
    01/06/14 21:50:00;302.8;0.7;21.6;53.9;-99.9
    01/06/14 22:50:00;294.2;1.1;19.3;67.4;-99.9
    01/06/14 23:50:00;308.5;1.0;17.5;72.4;-99.9
    ", file=zz)
    
    datos=read.csv(zz, sep=";", header=TRUE, na.strings="-99.9")
    

    Convert dates to POSIXct and print:

    library(ggplot2)
    
    datos=read.csv(zz, sep=";", header=TRUE, na.strings="-99.9")
    
    datos$dia=as.POSIXct(datos[,1], format="%y/%m/%d %H:%M:%S")  
    
    ggplot(data=datos,aes(x=dia, y=TEMP_M)) + 
      geom_path(colour="red") + 
      ylab("Temperatura (ºC)") + 
      xlab("Fecha") + 
      opts(title="Temperatura media") 
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following data set that I am trying to plot with ggplot2,
I'm trying to plot two sets of data wrt to time on the same
I'm trying to plot heatmap in ggplot2 using csv data following casbon's solution in
I'm having some problems trying to plot two different data sets from stdin in
I am trying plot data sets consisting of 3 coordinates: X-coordinate, x-coordinate and the
I am trying to plot the following ! from numpy import * from pylab
I'm trying to annotate a polar plot with data tips labelled with 'R:...,Theta:...' where
I am trying to make a faceted plot in ggplot2 of the coefficients on
As I am trying to plot a few financial time series in Mathematica, I
I am trying to plot side by side the following datasets dataset1=data.frame(obs=runif(20,min=1,max=10)) dataset2=data.frame(obs=runif(20,min=1,max=20)) dataset3=data.frame(obs=runif(20,min=5,max=10))

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.