| hm_plot | R Documentation | 
ggplot2 or plotly (interactive)This method allows you to make plots (using simple and expressive arguments)
of the variables contained inside an hydromet_XXX class object.
The plot outputs can be static (ggplot2) or dynamic (plotly).
hm_plot(
  obj,
  slot_name,
  col_name,
  interactive = FALSE,
  line_type = NULL,
  line_color = NULL,
  line_size = NULL,
  line_alpha = NULL,
  x_lab = "date",
  y_lab = "y",
  title_lab = NULL,
  legend_lab = NULL,
  dual_yaxis = NULL,
  from = NULL,
  to = NULL,
  scatter = NULL
)
## S4 method for signature 'hydromet_station'
hm_plot(
  obj,
  slot_name,
  col_name,
  interactive = FALSE,
  line_type = NULL,
  line_color = NULL,
  line_size = NULL,
  line_alpha = NULL,
  x_lab = "date",
  y_lab = "y",
  title_lab = NULL,
  legend_lab = NULL,
  dual_yaxis = NULL,
  from = NULL,
  to = NULL,
  scatter = NULL
)
## S4 method for signature 'hydromet_compact'
hm_plot(
  obj,
  slot_name,
  col_name,
  interactive = FALSE,
  line_type = NULL,
  line_color = NULL,
  line_size = NULL,
  line_alpha = NULL,
  x_lab = "date",
  y_lab = "y",
  title_lab = NULL,
  legend_lab = NULL,
  dual_yaxis = NULL,
  from = NULL,
  to = NULL,
  scatter = NULL
)
| obj | a valid  | 
| slot_name | string vector with the name of the slot(s) to use in plotting. | 
| col_name | list containing the column name of the variables to plot. Every element inside the list belongs to the previous defined slot(s). | 
| interactive | logical. Default value,  | 
| line_type | string with the name of the line dash type ( | 
| line_color | string with a valid  | 
| line_size | numeric vector containing the size of every line to plot. If you use
the  | 
| line_alpha | numeric vector with line(s) transparency. From 0 (invisible) to 1. | 
| x_lab | string with  | 
| y_lab | string with  | 
| title_lab | string with the title of the plot. Default is a plot without title. | 
| legend_lab | string vector with plot label(s) name(s). | 
| dual_yaxis | string vector suggesting which variables are assign either to
the  | 
| from | string value for  | 
| to | string value for  | 
| scatter | string vector (of length two) suggesting which variables goes in
the  | 
A ggplot2 or plotly object.
hm_plot(hydromet_station): plot method for station class
hm_plot(hydromet_compact): plot method for compact class
## Not run: 
# lets work with the cuevas station
path <- system.file('extdata', package = 'hydrotoolbox')
# use the build method
hm_cuevas <-
  hm_create() %>%
  hm_build(bureau = 'ianigla', path = path,
           file_name = 'ianigla_cuevas.csv',
           slot_name = c('tair', 'rh', 'patm',
                         'precip', 'wspd', 'wdir',
                         'kin', 'hsnow', 'tsoil'),
           by = 'hour',
           out_name = c('tair(°C)', 'rh(%)', 'patm(mbar)',
                        'p(mm)', 'wspd(km/hr)', 'wdir(°)',
                        'kin(kW/m2)', 'hsnow(cm)', 'tsoil(°C)' )
           )
# let's start by making a single variable static plot
hm_plot(obj = hm_cuevas, slot_name = 'tair',
        col_name = list('tair(°C)') )
# we add labels, change color, line type and we focus
# on specific date range
hm_plot(obj = hm_cuevas, slot_name = 'tair',
        col_name = list('tair(°C)'),
        line_type = 'longdash',
        line_color = 'dodgerblue',
        x_lab = 'Date time', y_lab = 'T(°C)',
        title_lab = 'Hourly temperature at Cuevas',
        legend_lab = 'Tair',
        from = ISOdate(2020, 7, 1),
        to = ISOdate(2020, 7, 5))
# compare air with soil temperature
hm_plot(obj = hm_cuevas, slot_name = c('tair', 'tsoil'),
        col_name = list('tair(°C)', 'tsoil(°C)'),
        line_type = c('longdash', 'solid'),
        line_color = c('dodgerblue', 'tan4'),
        x_lab = 'Date time', y_lab = 'T(°C)',
        title_lab = 'Hourly temperature at Cuevas',
        legend_lab = c('Tair', 'Tsoil'),
        from = ISOdate(2020, 7, 1),
        to = ISOdate(2020, 7, 5))
# let's add relative humidity on the right y-axis
hm_plot(obj = hm_cuevas, slot_name = c('tair', 'tsoil', 'rh'),
        col_name = list('tair(°C)', 'tsoil(°C)', 'rh(%)'),
        line_type = c('longdash', 'solid', 'solid'),
        line_color = c('dodgerblue', 'tan4', 'red'),
        x_lab = 'Date time', y_lab = c('T(°C)', 'RH(%)'),
        title_lab = 'Hourly meteo data at Cuevas',
        legend_lab = c('Tair', 'Tsoil', 'RH'),
        dual_yaxis = c('left', 'left', 'right'),
        from = ISOdate(2020, 7, 1),
        to = ISOdate(2020, 7, 5))
# we decide to analize the previous variables in detail
# with a dynamic plot
hm_plot(obj = hm_cuevas, slot_name = c('tair', 'tsoil', 'rh'),
        col_name = list('tair(°C)', 'tsoil(°C)', 'rh(%)'),
        line_color = c('dodgerblue', 'tan4', 'red'),
        x_lab = 'Date time', y_lab = c('T(°C)', 'RH(%)'),
        title_lab = 'Hourly meteo data at Cuevas',
        legend_lab = c('Tair', 'Tsoil', 'RH'),
        dual_yaxis = c('left', 'left', 'right'),
        interactive = TRUE)
# click on the Zoom icon and play a little...
# suppose now that we want to make a scatter plot to show
# the negative correlation between air temperature and
# relative humidity
hm_plot(obj = hm_cuevas, slot_name = c('tair', 'rh'),
        col_name = list('tair(°C)', 'rh(%)'),
        line_color = 'dodgerblue',
        x_lab = 'Tair', y_lab = 'RH',
        scatter = c('x', 'y') )
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.