22# '
33# ' The logo needs to be in the package extdata/logo folder as png file
44# '
5- # '
65# ' @param logo_filename Filename including .png ending
76# ' @param position One of "bottomright", "bottomleft", "bottom", "right", "left",
87# ' "center", "topright", "topleft" or "top".
@@ -43,16 +42,16 @@ add_logo <- function(
4342 system.file(package = " qsimVis" , " extdata/logos" ),
4443 logo_filename ), native = TRUE
4544 )
46-
4745 logo_size <- dim(logo )
48- logo_y_scale <- logo_size [1 ] / logo_size [2 ]
46+ logo_y_ratio <- logo_size [1 ] / logo_size [2 ]
4947
50- # into x and y values ranges in plot and margin
5148 x_plot_value_range <- diff(par(" usr" )[1 : 2 ])
52- x_total_value_range <- x_plot_value_range / diff(par(" plt" )[1 : 2 ])
49+ x_plot_inch_range <- par(" pin" )[1 ]
50+ x_values_per_inch <- x_plot_value_range / x_plot_inch_range
5351
5452 y_plot_value_range <- diff(par(" usr" )[3 : 4 ])
55- y_total_value_range <- y_plot_value_range / diff(par(" plt" )[3 : 4 ])
53+ y_plot_inch_range <- par(" pin" )[2 ]
54+ y_values_per_inch <- y_plot_value_range / y_plot_inch_range
5655
5756 if (position %in% c(" bottomright" , " topright" , " right" )){
5857 # definition of dimenstion based on x scale (1/10 of plot in x dimension)
@@ -70,9 +69,13 @@ add_logo <- function(
7069
7170 # calculation into relative values to get y dimensions
7271 x_logo_value_range <- xright - xleft
73- x_logo_value_share <- x_logo_value_range / x_total_value_range
74- y_logo_value_share <- x_logo_value_share * logo_y_scale
75- y_logo_value_range <- y_logo_value_share * y_total_value_range
72+ x_logo_inch_range <- x_logo_value_range / x_values_per_inch
73+ y_logo_inch_range <- x_logo_inch_range * logo_y_ratio
74+ y_logo_value_range <- y_logo_inch_range * y_values_per_inch
75+
76+ # x_logo_value_share <- x_logo_value_range / x_total_value_range
77+ # y_logo_value_share <- x_logo_value_share * logo_y_scale / device_y_scale
78+ # y_logo_value_range <- y_logo_value_share * y_total_value_range
7679
7780 if (position %in% c(" bottomleft" , " bottom" , " bottomright" )){
7881 ybottom <- par(" usr" )[3 ] + y_plot_value_range / 10 * indent
0 commit comments