I have 300 variables (columns) taken at 10 timepoints (rows), for each variable at any given timepoint I have temperature values A and F.
Attached is a sample of the dataframe
structure(list(Timepoint = c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L,
5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 9L, 13L, 13L, 25L, 25L),
Temperature = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("A",
"F"), class = "factor"), Concentration.of.chylomicrons = c(1.29e-11,
1.25e-11, 1.02e-11, 1.1e-11, 1.08e-11, 1.3e-11, 1.28e-11,
1.26e-11, 1.06e-11, 1.32e-11, 8.85e-12, 1.21e-11, 8.83e-12,
1.08e-11, 1.35e-11, 1.12e-11, 8.99e-12, 1.08e-11, 9.55e-12,
1.04e-11, 0, 1.01e-11), Total.lipids = c(0.00268, 0.0026,
0.00208, 0.00225, 0.00222, 0.0027, 0.00268, 0.0026, 0.00219,
0.00273, 0.0018, 0.00247, 0.00179, 0.00221, 0.00276, 0.00229,
0.00182, 0.00222, 0.00195, 0.00212, 0, 0.00204), Phospholipids = c(0.000224,
0.000223, 0.000145, 0.00016, 0.000157, 0.000211, 0.00023,
0.000211, 0.000165, 0.000224, 0.000109, 0.00018, 0.000113,
0.000163, 0.000175, 0.000177, 0.000122, 0.000173, 0.000127,
0.000156, 0, 0.000138)), .Names = c("Timepoint", "Temperature",
"Concentration.of.chylomicrons", "Total.lipids", "Phospholipids"
), class = "data.frame", row.names = c(NA, -22L))
I would like to draw a line graph to show how each variable varies with time. On this line graph I would like the A and F lines to be drawn.I have successfully managed to write the loop code for this.
# subset based on temperatures A and F
a_df <- subset(df, Temperature == "A")
f_df <- subset(df, Temperature == "F")
# loop from columns 3:x
for (i in 3:x) {
plot(a_df[, 1],
a_df[, i],
type = "l",
ylab = colnames(a_df[i]),
xlab = "Timepoint",
lwd = 2,
col = "blue")
lines(f_df[, 1],
f_df[, i],
type = "l",
lwd = 2,
col = "red")
legend("bottomleft",
col = c("blue", "red"),
legend = c("Temperature A", "Temperature F"),
lwd = 2,
y.intersp = 0.5,
bty = "n")
}
However for certain variables, certain points are outside the plot area, image attached below
Please click on this link for image
How can I make sure that in this loop command I can have graghs with all points visible. Im sure there is a quick way to fix this, can anyone help?
I have tried the following line, kindly suggested
ylim = c(min(f_df[,-1] ,max(f_df[,-1]),
I get the following error message
for (i in 3:229) {
+ plot(a_df[, 1],
+ a_df[, i],
+ type = "b",
+ ylim = c(min(f_df[,-1] ,max(f_df[,-1]),
+ ylab = colnames(f_df[i]),
+ main = colnames(f_df[i]),
+ xlab = "Timepoint",
+ lwd = 2,
+ col = "red")
+ lines(f_df[, 1],
Error: unexpected symbol in:
" col = "red")
lines"
f_df[, i],
Error: unexpected ',' in " f_df[, i],"
type = "b",
Error: unexpected ',' in " type = "b","
lwd = 2,
Error: unexpected ',' in " lwd = 2,"
col = "blue")
Error: unexpected ')' in " col = "blue")"
legend("bottomleft",
+ col = c("red", "blue"),
+ legend = c("Ambient", "Fridge"),
+ lwd = 2,
+ y.intersp = 0.5,
+ bty = "n")
Error in strwidth(legend, units = "user", cex = cex, font = text.font) :
plot.new has not been called yet
}
Error: unexpected '}' in "}"
Lakmal
To recap in an answer. Setting ylim solves the issue
# loop from columns 3:x
for (i in 3:x) {
plot(a_df[, 1],
a_df[, i],
type = "l",
ylab = colnames(a_df[i]),
xlab = "Timepoint",
ylim = c(min(df[,-1]) ,max(df[,-1])),
lwd = 2,
col = "blue")
...
sets the plot boundaries as equal for each plot which is better if you want to compare the plots but has the downside that the plot area might be considerably larger than your data.
# loop from columns 3:x
for (i in 3:x) {
plot(a_df[, 1],
a_df[, i],
type = "l",
ylab = colnames(a_df[i]),
xlab = "Timepoint",
ylim = c(min(df[,i]) ,max(df[,i])),
lwd = 2,
col = "blue")
...
sets new boundaries for each plot, which is worse for comparison but reduces unnecessary empty plot space. I've replaced min(a_df[, i],f_df[, i])with min(df[,i]) since they should be identical.
Related
When I add a text line to a geom_line plot, the line disappears.
library(tidyverse)
library("lubridate")
library(plotly)
library("RColorBrewer")
library(htmlwidgets)
library("reprex")
activity <- c("N", "FB", "N", "N", "N", "FA", "N", "FA", "N", "FA", "N", "N", "N", "N", "N", "FA", "N", "N", "N", "N", "FA", "N", "N", "FA", "FA")
activity_date <- as.Date(c(NA, "2022-04-19", "2022-05-01", "2022-05-01", "2022-05-06", "2022-05-06", "2022-05-07", "2022-05-07", "2022-05-09", "2022-05-09", "2022-05-10", "2022-05-13", "2022-05-14", "2022-05-14", "2022-05-14", "2022-05-15", "2022-05-15", "2022-05-15", "2022-05-15", "2022-05-15", "2022-05-16", "2022-05-16", "2022-05-16", "2022-05-16", "2022-05-16"))
fcrawl_cum <- c(0L, 1L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 7L, 8L)
clutch_cum <- c(1L, 1L, 2L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 8L, 9L, 10L, 11L, 11L, 12L, 13L, 14L, 15L, 15L, 16L, 17L, 17L, 17L)
turtle_activity_gtm <- tibble(activity, activity_date, fcrawl_cum, clutch_cum)
the_pal <- RColorBrewer::brewer.pal(n = 8,"Dark2") #Set color palette.
myplot2 <-
ggplot() +
geom_line(data = turtle_activity_gtm,
aes(x=activity_date, y=fcrawl_cum,
text = paste("Date: ", as.Date(activity_date),
"<br>Total: ", fcrawl_cum)),
na.rm = TRUE,
linetype = "111111",
linewidth = 1.5, color = the_pal[6]) +
geom_line(data = turtle_activity_gtm,
aes(x=activity_date, y=clutch_cum),
na.rm = TRUE,
linewidth = 1.5,
color = the_pal[7]) +
labs(title = "myplot2")
myplot2
ggplotly(myplot2)
ggplotly(myplot2, tooltip = c("text"))
If I use, ggplotly(myplot2) the line with the text line added is still not there. However, the data points still appear for missing line. If I use ggplotly with the added tooltip, ggplotly(myplot2, tooltip = c("text")) ,the label is missing for the line without the added text line but the label is exactly as written in the text line.
I would show some of the plots; however, I am not allow to yet. Reputation too low.
How can I do this properly so that both lines show with the added tooltip? I eventually want both lines to have their own text lines added. This is a very simplified chart. One I can get past this problem, I plan to eventually add a lot more items to this chart with a full data set.
Thanks,
Jeff
When adding the text attribute to geom_line you have to explicitly set the group aesthetic, i.e. use e.g. group=1 to tell ggplot2 that all observations belong to one group which for simplicity I called 1:
library(tidyverse)
library(plotly)
myplot2 <-
ggplot() +
geom_line(
data = turtle_activity_gtm,
aes(
x = activity_date, y = fcrawl_cum, group = 1,
text = paste(
"Date: ", as.Date(activity_date),
"<br>Total: ", fcrawl_cum
)
),
na.rm = TRUE,
linetype = "111111",
linewidth = 1.5, color = the_pal[6]
) +
geom_line(
data = turtle_activity_gtm,
aes(x = activity_date, y = clutch_cum),
na.rm = TRUE,
linewidth = 1.5,
color = the_pal[7]
) +
labs(title = "myplot2")
#> Warning in geom_line(data = turtle_activity_gtm, aes(x = activity_date, :
#> Ignoring unknown aesthetics: text
ggplotly(myplot2, tooltip = c("text"))
EDIT TBMK there is only one text attribute, i.e. specify your tooltip via text the same way as for the first geom_line and use tooltip=c("text").
But a more ggplot2 like approach to create your chart would be to first reshape your data to long format. Doing so allows to create your plot with just one geom_line but requires map on the color aes, to map on the group aes appropriately and to set your colors via scale_color_manual. Note that doing so will automatically add a legend to your plot:
turtle_activity_gtm_long <- turtle_activity_gtm %>%
tidyr::pivot_longer(c(fcrawl_cum, clutch_cum))
ggplot() +
geom_line(
data = turtle_activity_gtm_long,
aes(
x = activity_date, y = value,
color = name, group = name,
text = paste(
"Date: ", as.Date(activity_date),
"<br>Total: ", value
)
),
na.rm = TRUE,
linewidth = 1.5
) +
scale_color_manual(values = c(clutch_cum = the_pal[[7]], fcrawl_cum = the_pal[[6]])) +
labs(title = "myplot2")
ggplotly(tooltip = c("text"))
Despite having tried many types of lines, I just cannot get the same result.
Here is how I need the lines to look:
And this is how I got it so far (and am stuck at):
Here is my code:
myData <- read.csv(file.choose(), header = TRUE)
require(ggplot2)
g <- ggplot(myData, aes(speed, resp))
g + geom_point(aes(color = padlen, shape = padlen)) +
geom_smooth(method = "lm", formula = y ~ splines::bs(x, df = 4, degree = 2), se = FALSE, aes(color = padlen), linetype = "solid", size = 1) +
scale_color_manual(values = c("red", "black")) +
scale_shape_manual(values = c(2, 1))
And here is the database (dput):
myData <- structure(list(resp = c(0, 0.125, 0.583333333, 1, 0.958333333,
1, 0, 0.041666667, 0.25, 0.916666667, 1, 1), padlen = structure(c(2L,
2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("big",
"small"), class = "factor"), speed = c(2L, 3L, 4L, 5L, 6L, 7L,
2L, 3L, 4L, 5L, 6L, 7L)), .Names = c("resp", "padlen", "speed"
), class = "data.frame", row.names = c(NA, -12L))
I have also tried all these polynomial models (and others), but none works:
## Quadratic model
lmQuadratic <- lm(formula = y ~ x + I(x^2),
data = fpeg)
## Cubit model
lmCubic <- lm(formula = y ~ x + I(x^2) + I(x^3),
data = fpeg)
## Fractional polynomial model
lmFractional <- lm(formula = y ~ x + I(x^2) + I(x^(1/2)),
data = fpeg)
So, what should I do/not do to get my lines the same as the original ones? Thanks.
Instead of using method = "lm" in the geom_smooth-function use the glm with the binomial family. The glm-smooth gives you only values between 0 and 1 (what you want to have, because you're dealing with proportion).
library(ggplot2)
ggplot(myData, aes(speed, resp)) +
geom_point(aes(color = padlen, shape = padlen)) +
geom_smooth(method = "glm", method.args = list(family = "binomial"),
se = FALSE, aes(color = padlen), linetype = "solid", size = 1) +
scale_color_manual(values = c("red", "black")) +
scale_shape_manual(values = c(2, 1)) +
theme_classic()
Data
myData <-
structure(list(resp = c(0, 0.125, 0.583333333, 1, 0.958333333, 1, 0,
0.041666667, 0.25, 0.916666667, 1, 1),
padlen = c("small", "small", "small", "small", "small",
"small", "big", "big", "big", "big", "big", "big"),
speed = c(2L, 3L, 4L, 5L, 6L, 7L, 2L, 3L, 4L, 5L, 6L, 7L)),
.Names = c("resp", "padlen", "speed"), class = "data.frame",
row.names = c(NA, -12L))
I wanted to create 3D scatter plot in R plotly and add ellipses to each cluster of plot using updatemenue. (Something similar to "Relayout Button" section in https://plot.ly/r/custom-buttons/#relayout-button but for 3D one). I'm able to add ellipses using ellipse3d to plotly plot but I don't know how to make it interactive with updatemenue layout.
I wrote below code but not adding updatemenus yet. Would you please give me a help?
df<-
structure(list(C = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L,
3L, 3L, 4L, 4L, 4L), .Label = c("h", "j", "k", "l"), class = "factor"),
R = structure(c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L,
2L, 3L), .Label = c("a", "b", "c"), class = "factor"),
p1 = c(-58.2553800845032, -56.8446241583638, -57.4730903743034,
9.69295162882175, 23.2783600609086, 17.5961245834489, 27.1776771896781,
31.8555589999195, 31.1329423894753, 5.49176565720366, 12.9720812431292,
13.3756328645854), p2 = c(1.89343789795219, 2.96630118684064,
3.36783254906029, 22.1036613994383, 19.1821210966211, 26.161634708624,
0.00600630960161123, 6.18082767371698, 1.73282189156538,
-26.351364716711, -26.6021818789505, -30.641098117759), p3 = c(1.98930539820297,
3.3628193816464, 4.50430994627108, -16.0161352497141, -10.0505758631406,
-3.19889710494869, 8.92935203885341, 7.00720243933593, 22.7494673296249,
-11.7929746942337, -5.26783717642642, -2.21603644547113)), .Names = c("C",
"R", "p1", "p2", "p3"), class = "data.frame", row.names = c(NA,
-12L))
library(plotly)
library(corpcor)
library(rgl)
x=df$p1; y=df$p2; z=df$p3
col <- c("orange", "blue", "purple", "green")
p <- plot_ly(df, x =x, y = y, z = z,type = "scatter3d",
mode = "markers", marker = list(color = col[df$C],
showscale = FALSE)
#, text = paste(df$C, df$R)
)
groups <- df$C
levs <- levels(groups)
group.col <- c("red", "blue", "yellow", "green")
for (i in 1:length(levs)) {
group <- levs[i]
selected <- groups == group
xx <- x[selected]; yy <- y[selected]; zz <- z[selected]
co<- cov(cbind(xx,yy,zz))
S<- make.positive.definite(co)
ellips <- ellipse3d(S, centre=c(mean(xx),mean(yy),mean(zz)), level = 0.95)
p<- add_trace(p, x = ellips$vb[1,], y = ellips$vb[2,], z = ellips$vb[3,]
,type = 'scatter3d', size = 1
,opacity=0.002
#,color= group.col[i]
,showlegend = FALSE)
}
print(p)
I am working on the dataset reported here below (pre.sss)
pre.sss <- pre.sss <- structure(list(Pretest.num = c(63, 62, 61, 60, 59, 58, 57, 4,2, 1), stress = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 2L,1L), .Label = c("[0,6]", "(6,9]"), class = "factor"), time = c(1L,1L, 1L, 1L, 1L, 1L, 1L, 8L, 8L, 8L), after = structure(c(2L,2L, 2L, 2L, 2L, 2L, 1L, 1L, NA, 1L), .Label = c("no", "yes"), class = "factor"),id = c("call_fam", "call_fam", "call_fam", "call_fam", "call_fam","call_fam", "call_fam", "counselor", "counselor", "counselor")), .Names = c("Pretest.num", "stress", "time", "after","id"), reshapeLong = structure(list(varying = structure(list(after = c("after.call.fam", "after.speak", "after.send.email","after.send.card", "after.attend", "after.fam.mtg", "after.sup.grp","after.counselor")), .Names = "after", v.names = "after", times = 1:8),v.names = "after", idvar = "Pretest.num", timevar = "time"), .Names = c("varying","v.names", "idvar", "timevar")), row.names = c("63.1", "62.1","61.1", "60.1", "59.1", "58.1", "57.1", "4.8", "2.8", "1.8"), class = "data.frame")
and I need to plot the counts of several categorical variables according to a specific level of another categorical variable ('stress'): so, a faceted bobble-lot would do the job in my case
So what I do is the following:
ylabels = c('call_fam' = "call fam.member for condolences",
'speak' = "speak to fam.member in person",
'send.email' = "send condolence email to fam.member",
'send.card' = "send condolence card/letter to fam.member",
'attend' = "attend funeral/wake",
'fam.mtg' = "provide fam.meeting",
'sup.grp' = "suggest attending support grp.",
'counselor' = "make referral to bereavement counselor" )
p = ggplot(pre.sss, aes(x = after, y = id)) +
geom_count(alpha = 0.5, col = 'darkblue') +
scale_size(range = c(1,30)) +
theme(legend.position = 'none') +
xlab("Response") +
ylab("What did you do after learning about death?") +
scale_y_discrete(labels = ylabels) +
facet_grid(.~ pre.sss$stress, labeller = as_labeller(stress.labels))
and I obtain the following image, exactly as I want.
Now I would like to label each bubble with the count with which the corresponding data appear in the dataset.
dat = data.frame(ggplot_build(p)$data[[1]][, c('x', 'y', 'PANEL', 'n')])
dat$PANEL = ifelse(dat$PANEL==1, "[0,6]", "(6-9]")
colnames(dat) = c('x', 'y', 'stress', 'n')
p + geom_text(aes(x, y, label = n, group = NULL), data = dat)
This gives me the following error I really can't understand.
> p + geom_text(aes(x, y, label=n, group=NULL), data=dat)
Error in `$<-.data.frame`(`*tmp*`, "PANEL", value = c(1L, 1L, 1L, 1L, :
replacement has 504 rows, data has 46
Can anybody help me with this?
Thanks!
EM
The function you refer to as your labeller function is missing from this example still. geom_count uses stat_sum, which calculates a parameter n, the number of observations at that point. Because you can use this calculated parameter, you don't actually have to assign the plot to a variable and pull out its data, as you did with ggplot_build.
This should do what you're looking for:
ggplot(pre.sss, aes(x = after, y = id)) +
geom_count(alpha = 0.5, col = 'darkblue') +
# note the following line
stat_sum(mapping = aes(label = ..n..), geom = "text") +
scale_size(range = c(1,30)) +
theme(legend.position = 'none') +
xlab("Response") +
ylab("What did you do after learning about death?") +
scale_y_discrete(labels = ylabels) +
facet_grid(.~ stress)
The line I added computes the same thing as what's behind the scenes in geom_count, but gives it a text geom instead, with the label mapped to that computed parameter n.
The following code modified from an earlier post produces a plot window containing a pie-chart. I would like to be able to place multiple pie charts in the window, but am having trouble with placement. Successive calls to the pie chart function do not populate the plot in the order I expect (two pie charts are placed in opposite corners of the plot, and then further calls do not add any more pie charts, even though there is space). Is there any way to correct this? I eventually need 6 pie charts (3 rows and 2 columns).
rm(list = ls(all = TRUE))
# DATA
mydf <- structure(list(inner_category = structure(c(3L, 3L, 3L, 3L, 2L, 2L,
2L, 1L, 5L, 5L, 4L), .Label = c("group1", "group2", "group3",
"group4", "group5"), class = "factor"), outer_category = structure(c(5L,
6L, 7L, 8L, 2L, 3L, 4L, 1L, 10L, 11L, 9L), .Label = c("group1_A",
"group1_B", "group1_C", "group1_D", "group2_A", "group2_B",
"group2_C", "group2_D", "group3_A", "group4_A", "group4_B"),
class = "factor"), share = c(10.85, 7.35, 33.06, 2.81, 1.58,
13.12, 5.43, 9.91, 1.42, 4.55, 1.65)), .Names = c("inner_category", "outer_category", "share"),
row.names = c(NA, -11L), class = "data.frame")
mydf$total <- with(mydf1, ave(share, inner_category, FUN = sum))
# PLOTTING WINDOW
quartz("Quartz", width=9, height=8, pointsize=18)
par(mfrow=c(3,2), mar=c(4,4,2,0.5), mgp = c(1.5, 0.3, 0), tck = -0.01)
#FUNCTION
donutplotfunction <- function(myfile, width = 15, height = 11) {
## HOUSEKEEPING
if (missing(myfile)) file <- getwd()
op <- par(no.readonly = TRUE); on.exit(par(op))
nr <- nrow(myfile)
width <- max(sqrt(myfile$share)) / 0.8
tbl <- with(myfile, table(inner_category)[order(unique(inner_category))])
cols <- c('cyan2','red','orange','green','dodgerblue2')
cols <- unlist(Map(rep, cols, tbl))
## LOOP TO CREATE PIE SLICES
par(omi = c(0.5,0.5,0.75,0.5), mai = c(0.1,0.1,0.1,0.1), las = 1)
for (i in 1:nr) {
par(new = TRUE)
## CREATE COLORS AND SHADES
rgb <- col2rgb(cols[i])
f0 <- rep(NA, nr)
f0[i] <- rgb(rgb[1], rgb[2], rgb[3], 190 / sequence(tbl)[i], maxColorValue = 255)
## CREATE LABELS FOR THE OUTERMOST SECTION
lab <- with(myfile, sprintf('%s: %s', outer_category, share))
if (with(myfile, share[i] == max(share))) {
lab0 <- lab
} else lab0 <- NA
## PLOT THE OUTSIDE PIE AND SHADES OF SUBGROUPS
par(lwd = 0.1)
pie(myfile$share, border = "white", radius = 5 / width, col = f0, labels = lab0, cex = 0.7, ticks = 0)
## REPEAT ABOVE FOR THE MAIN GROUPS
par(new = TRUE)
rgb <- col2rgb(cols[i])
f0[i] <- rgb(rgb[1], rgb[2], rgb[3], maxColorValue = 255)
par(lwd = 0.1)
pie(myfile$share, border = "white", radius = 4 / width, col = f0, labels = NA)
}
## GRAPH TITLE
text(x = c(-.05, -.05, 0.15, .25, .3), y = c(.08, -.12, -.15, -.08, -.02), labels = unique(myfile$inner_category), col = 'black', cex = 0.8)
mtext('Figure Main Title', side = 3, line = -1, adj = 0, cex = 1, outer = TRUE)
}
donutplotfunction(mydf)
First, a couple of tips. (1) It is easier for people to help if you post a minimal example. Your code has a lot of details that aren't relevant to the problem--try to eliminate such code. (2) Since rgb is a function name, try to avoid using rgb for a variable name. (3) You don't need to loop over pie slices--just have R draw all slices at once. (4) You had too many par(new=TRUE) statements.
I think the following code is the essence of what you want.
mydf <- structure(list(inner_category = structure(c(3L, 3L, 3L, 3L, 2L, 2L,
2L, 1L, 5L, 5L, 4L), .Label = c("group1", "group2", "group3",
"group4", "group5"), class = "factor"), outer_category = structure(c(5L,
6L, 7L, 8L, 2L, 3L, 4L, 1L, 10L, 11L, 9L), .Label = c("group1_A",
"group1_B", "group1_C", "group1_D", "group2_A", "group2_B",
"group2_C", "group2_D", "group3_A", "group4_A", "group4_B"),
class = "factor"), share = c(10.85, 7.35, 33.06, 2.81, 1.58,
13.12, 5.43, 9.91, 1.42, 4.55, 1.65)), .Names = c("inner_category", "outer_category", "share"),
row.names = c(NA, -11L), class = "data.frame")
donutplotfunction <- function(myfile, width = 7) {
tbl <- with(myfile, table(inner_category)[order(unique(inner_category))])
cols <- c('cyan2','red','orange','green','dodgerblue2')
cols <- unlist(Map(rep, cols, tbl))
rg <- col2rgb(cols)
col.lt <- rgb(rg[1,], rg[2,], rg[3,], alpha = 190 / sequence(tbl), maxColorValue = 255)
col.dk <- rgb(rg[1,], rg[2,], rg[3,], maxColorValue = 255)
# Outside pie
pie(myfile$share, border = "white", radius = 5 / width, col = col.lt, cex = 0.7)
# Inside pie. Use 'new' to get overplotting
par(new = TRUE)
pie(myfile$share, border = "white", radius = 4 / width, col = col.dk, labels = NA)
}
#windows()
par(mfrow=c(3,2), mar=c(4,4,2,0.5), mgp = c(1.5, 0.3, 0), tck = -0.01)
donutplotfunction(mydf)
donutplotfunction(mydf)
donutplotfunction(mydf) # etc