@@ -859,27 +859,29 @@ get_dimensions = function(x, n_out, unit.default, page_dim, page_dim_net){
859859# ' at the default size will be at the defined point size.
860860# '
861861# ' @inheritParams png_fit
862- # ' @param file Character scalar. The name of the file in which to save the graph.
863- # ' If the argument type is `NULL`, the type of file is deduced from the extension.
862+ # ' @param file Character scalar or `NULL` . The name of the file in which to save the graph.
863+ # ' If the argument ` type` is `NULL`, the type of file is deduced from the extension.
864864# ' If your file extension is different from your file type, you need to use the
865- # ' argument `type`.
865+ # ' argument `type`. It `file = NULL`, no graph is exported but, if provided,
866+ # ' the graphical parameters are modified accordingly.
866867# ' @param type Character scalar, default is `NULL`. The type of file to be created.
867868# ' If `NULL`, the default, then the type of file is deduced from the extension.
868869# ' @param margin Numeric vector, default is `NULL`. Defines the size of the four
869- # ' plotting margins. If of length 1 or 2, the content is recycled to fit 4 elements.
870- # ' By default the unit is the line but you can change it with the argument
870+ # ' plotting margins (in this order: bottom, left, top, right).
871+ # ' If of length 1 or 2, the content is recycled to fit 4 elements.
872+ # ' By default the unit is the "line" but you can change it with the argument
871873# ' `margin.unit`.
872874# ' @param margin.left Numeric scalar, default is `NULL`. The size of the left margin.
873- # ' By default the unit is the line but you can change it with the argument
875+ # ' By default the unit is the " line" but you can change it with the argument
874876# ' `margin.unit`.
875877# ' @param margin.right Numeric scalar, default is `NULL`. The size of the right margin.
876- # ' By default the unit is the line but you can change it with the argument
878+ # ' By default the unit is the " line" but you can change it with the argument
877879# ' `margin.unit`.
878880# ' @param margin.top Numeric scalar, default is `NULL`. The size of the top margin.
879- # ' By default the unit is the line but you can change it with the argument
881+ # ' By default the unit is the " line" but you can change it with the argument
880882# ' `margin.unit`.
881883# ' @param margin.bottom Numeric scalar, default is `NULL`. The size of the bottom margin.
882- # ' By default the unit is the line but you can change it with the argument
884+ # ' By default the unit is the " line" but you can change it with the argument
883885# ' `margin.unit`.
884886# ' @param margin.unit Character scalar equal to either: i) "line" (default), ii) "inch", iii) "cm".
885887# ' @param box Can be equal to `NULL` (default), a logical scalar, or a character scalar.
@@ -888,28 +890,30 @@ get_dimensions = function(x, n_out, unit.default, page_dim, page_dim_net){
888890# ' If a character scalar, it should contain the following letters: "b", "l", "t" and/or "r",
889891# ' which stand for the bottom, left, top and right border.
890892# ' @param col.bg An R color, default is `NULL`. The background color of the plot.
891- # ' @param col.default A vector of R colors, default is `NULL`.
892- # ' They represent the default colors used for plotting.
893+ # ' @param col.default An R colors, default is `NULL`. They represent the default color
894+ # ' used for plotting (the axes will be drawn with that color and it will be the default
895+ # ' color when the argument `col` is not provided in plotting functions).
893896# ' @param lwd Numeric scalar, default is `NULL`. The default width of the lines.
894897# ' @param yaxis.horiz Logical, default is `NULL`. Whether to display the y-axis labels
895898# ' horizontally.
896899# ' @param outermargin Numeric vector, default is `NULL`. Defines the size of the four
897900# ' outer margins. If of length 1 or 2, the content is recycled to fit 4 elements.
898- # ' By default the unit is the line but you can change it with the argument
901+ # ' By default the unit is the " line" but you can change it with the argument
899902# ' `outermargin.unit`.
900- # ' @param outermargin.left Numeric scalar, default is `NULL`. The size of the left margin.
901- # ' By default the unit is the line but you can change it with the argument
903+ # ' @param outermargin.left Numeric scalar, default is `NULL`. The size of the left outer margin.
904+ # ' By default the unit is the " line" but you can change it with the argument
902905# ' `margin.unit`.
903- # ' @param outermargin.right Numeric scalar, default is `NULL`. The size of the right margin.
904- # ' By default the unit is the line but you can change it with the argument
906+ # ' @param outermargin.right Numeric scalar, default is `NULL`. The size of the right outer margin.
907+ # ' By default the unit is the " line" but you can change it with the argument
905908# ' `margin.unit`.
906- # ' @param outermargin.top Numeric scalar, default is `NULL`. The size of the top margin.
907- # ' By default the unit is the line but you can change it with the argument
909+ # ' @param outermargin.top Numeric scalar, default is `NULL`. The size of the top outer margin.
910+ # ' By default the unit is the " line" but you can change it with the argument
908911# ' `margin.unit`.
909- # ' @param outermargin.bottom Numeric scalar, default is `NULL`. The size of the bottom margin.
910- # ' By default the unit is the line but you can change it with the argument
912+ # ' @param outermargin.bottom Numeric scalar, default is `NULL`. The size of the bottom outer margin.
913+ # ' By default the unit is the " line" but you can change it with the argument
911914# ' `margin.unit`.
912- # ' @param outermargin.unit Character scalar equal to either: i) "line" (default), ii) "inch", iii) "cm".
915+ # ' @param outermargin.unit Character scalar equal to either: i) "line" (default),
916+ # ' ii) "inch", iii) "cm".
913917# ' @param square_plot Logical, default is `NULL`. Whether the plotting region should fit
914918# ' a square. If `FALSE` the plotting region is maximal.
915919# ' @param nrow Integer scalar, default is `NULL`. To display multiple graphs, the number of
@@ -936,6 +940,16 @@ get_dimensions = function(x, n_out, unit.default, page_dim, page_dim_net){
936940# '
937941# ' @details
938942# '
943+ # ' When the function `export_graph_end()` is called, the resulting exported graph
944+ # ' is displayed in the Viewer. The viewer function is found with
945+ # ' `getOption("viewer")` and should work on RStudio and VSCode (with the R extension).
946+ # '
947+ # ' When the graphical parameters are modified in `export_graph_start`, they are reset
948+ # ' once a call to `export_graph_end`, or new call to `export_graph_start`, is run.
949+ # '
950+ # ' When the argument `file = NULL` (default), the function `export_graph_start` can be
951+ # ' used in lieu of `par`, possibly facilitating the reset of the graphical parameters.
952+ # '
939953# ' To export a ggplot2 graph, remember that you need to **print** it!
940954# '
941955# ' ```
@@ -959,9 +973,7 @@ get_dimensions = function(x, n_out, unit.default, page_dim, page_dim_net){
959973# ' export_graph_end()
960974# ' ```
961975# '
962- # ' When the function `export_graph_end()` is called, the resulting exported graph
963- # ' is displayed in the Viewer. The viewer function is found with
964- # ' `getOption("viewer")` and should work on RStudio and VSCode (with the R extension).
976+ # '
965977# '
966978# ' @return
967979# ' These functions do not return anything in R. `export_graph_start` creates a
@@ -989,7 +1001,16 @@ get_dimensions = function(x, n_out, unit.default, page_dim, page_dim_net){
9891001# ' # graph in the viewer pane if appropritate
9901002# ' export_graph_end()
9911003# '
992- export_graph_start = function (file , pt = 10 , width = 1 , height , w2h = 1.75 , h2w ,
1004+ # ' # We create a 'normal' graph where we change a few graphical parameters
1005+ # ' export_graph_start(col.default = "deepskyblue1", title.col = "indianred1",
1006+ # ' title.italic = TRUE, title.size = 2)
1007+ # ' with(iris, plot(Sepal.Length, Petal.Length, pch = 18, cex = 2))
1008+ # ' title("Iris data set")
1009+ # ' # we reset the graphical parameters:
1010+ # ' export_graph_end()
1011+ # '
1012+ # '
1013+ export_graph_start = function (file = NULL , pt = 10 , width = 1 , height , w2h = 1.75 , h2w ,
9931014 sideways = FALSE , res = 300 , type = NULL ,
9941015 # mar
9951016 margin = NULL , margin.left = NULL , margin.right = NULL ,
@@ -1019,7 +1040,7 @@ export_graph_start = function(file, pt = 10, width = 1, height, w2h = 1.75, h2w,
10191040
10201041 mc = match.call()
10211042
1022- check_arg(file , " NULL path create mbt " )
1043+ check_arg(file , " NULL path create" )
10231044 check_arg(type , " NULL character scalar" )
10241045
10251046 #
@@ -1039,7 +1060,7 @@ export_graph_start = function(file, pt = 10, width = 1, height, w2h = 1.75, h2w,
10391060 check_arg(lwd , " NULL numeric scalar ge{0}" )
10401061
10411062 check_color(col.bg , scalar = TRUE , null = TRUE )
1042- check_color(col.default , null = TRUE )
1063+ check_color(col.default , scalar = TRUE , null = TRUE )
10431064
10441065 check_arg(nrow , ncol , " NULL integer scalar ge{1}" )
10451066 check_arg(byrow , " logical scalar" )
0 commit comments