mc_plot_line {myClim} | R Documentation |
Plot data - ggplot2 geom_line
Description
Function plots data with ggplot2 geom_line. Plot is returned as ggplot faced grid and is optimized for saving as facet, paginated PDF file.
Usage
mc_plot_line(
data,
filename = NULL,
sensors = NULL,
scale_coeff = NULL,
png_width = 1900,
png_height = 1900,
start_crop = NULL,
end_crop = NULL,
use_utc = TRUE,
localities = NULL,
facet = "locality"
)
Arguments
data |
myClim object see myClim-package |
filename |
output file name/path with the extension - supported formats are .pdf and .png (default NULL) If NULL then the plot is displayed and can be returned into r environment but is not saved to file. |
sensors |
names of sensors; if NULL then all (default NULL) see |
scale_coeff |
scale coefficient for secondary axis (default NULL) |
png_width |
width for png output (default 1900) |
png_height |
height for png output (default 1900) |
start_crop |
POSIXct datetime in UTC for crop data (default NULL) |
end_crop |
POSIXct datetime in UTC for crop data (default NULL) |
use_utc |
if FALSE, then the time shift from In the Agg-format myClim object |
localities |
names of localities; if NULL then all (default NULL) |
facet |
possible values (
|
Details
Saving as the PDF file is recommended, because the plot is optimized
to be paginate PDF (facet line plot is distributed to pages), each locality can be
represented by separate plot (facet = "locality"
) default, which is especially useful
for bigger data. When facet = NULL
then single plot is returned showing all localities together.
When facet = physical
sensors with identical physical units are grouped together across localities.
Maximal number of physical units (elements) of sensors to be plotted in one
plot is two. First element is related to primary and second to secondary y axis.
In case, there are multiple sensors with identical physical on one locality,
they are plotted together for facet = "locality"
e.g., when you have
TMS_T1, TMS_T2, TMS_T3, Thermo_T, and VWC you get plot with 5 lines of different colors and
two y axes. Secondary y axes are scaled with calculation values * scale_coeff
.
If scaling coefficient is NULL than function try to detects scale coefficient from
physical unit of sensors see mc_Physical. Scaling is useful when
plotting together e.g. temperature and moisture. For native myClim loggers
(TOMST, HOBO U-23) scaling coefficients are pre-defined.
For other cases when plotting two physicals together,
it is better to set scaling coefficients by hand.
Value
ggplot2 object
Examples
tms.plot <- mc_filter(mc_data_example_agg, localities = "A6W79")
p <- mc_plot_line(tms.plot,sensors = c("TMS_T3","TMS_T1","TMS_moist"))
p <- p+ggplot2::scale_x_datetime(date_breaks = "1 week", date_labels = "%W")
p <- p+ggplot2::xlab("week")
p <- p+ggplot2::scale_color_manual(values=c("hotpink","pink", "darkblue"),name=NULL)