source('~/.active-rstudio-document')
rm(list = ls())     # clear objects
graphics.off()      # close graphics windows
# Generate data
x = 0:10;
y = 0:10;
# Plot the data
# - Specify the layout parameters before any plotting
#   If you don't specify them before any plotting, the
#   results will be inconsistent and misaligned.
#
# - oma stands for 'Outer Margin Area', or the total margin space that is outside
#   of the standard plotting region (see graph)
#
# - The vector is ordered, the first value corresponding to the bottom. The entire
#   array is c(bottom, left, top, right)
#
# - All of the alternatives are:
#   - oma: Specify width of margins in number of lines
#   - omi: Specify width of margins in inches
#   - omd: Specify width of margins in 'device coordinates'
#       - Device coordinates place (0,0) in the upper left and (1,1) in the
#         lower right corner
par(oma=c(3,3,3,3))  # all sides have 3 lines of space
#par(omi=c(1,1,1,1)) # alternative, uncomment this and comment the previous line to try
# - The mar command represents the figure margins. The vector is in the same ordering of
#   the oma commands.
#
# - The default size is c(5,4,4,2) + 0.1, (equivalent to c(5.1,4.1,4.1,2.1)).
#
# - The axes tick marks will go in the first line of the left and bottom with the axis
#   label going in the second line.
#
# - The title will fit in the third line on the top of the graph.
#
# - All of the alternatives are:
#   - mar: Specify the margins of the figure in number of lines
#   - mai: Specify the margins of the figure in number of inches
par(mar=c(5,4,4,2) + 0.1)
#par(mai=c(2,1.5,1.5,.5)) # alternative, uncomment this and comment the previous line
# Plot
plot(x, y, type="n", xlab="X", ylab="Y")    # type="n" hides the points
# Place text in the plot and color everything plot-related red
text(5,5, "Plot", col="red", cex=2)
text(5,4, "text(5,5, \"Plot\", col=\"red\", cex=2)", col="red", cex=1)
box("plot", col="red")
# Place text in the margins and label the margins, all in green
mtext("Margins", side=3, line=2, cex=2, col="green")
mtext("par(mar=c(5,4,4,2) + 0.1)", side=3, line=1, cex=1, col="green")
mtext("Line 0", side=3, line=0, adj=1.0, cex=1, col="green")
mtext("Line 1", side=3, line=1, adj=1.0, cex=1, col="green")
mtext("Line 2", side=3, line=2, adj=1.0, cex=1, col="green")
mtext("Line 3", side=3, line=3, adj=1.0, cex=1, col="green")
mtext("Line 0", side=2, line=0, adj=1.0, cex=1, col="green")
mtext("Line 1", side=2, line=1, adj=1.0, cex=1, col="green")
mtext("Line 2", side=2, line=2, adj=1.0, cex=1, col="green")
mtext("Line 3", side=2, line=3, adj=1.0, cex=1, col="green")
box("figure", col="green")
# Label the outer margin area and color it blue
# Note the 'outer=TRUE' command moves us from the figure margins to the outer
# margins.
mtext("Outer Margin Area", side=1, line=1, cex=2, col="blue", outer=TRUE)
mtext("par(oma=c(3,3,3,3))", side=1, line=2, cex=1, col="blue", outer=TRUE)
mtext("Line 0", side=1, line=0, adj=0.0, cex=1, col="blue", outer=TRUE)
mtext("Line 1", side=1, line=1, adj=0.0, cex=1, col="blue", outer=TRUE)
mtext("Line 2", side=1, line=2, adj=0.0, cex=1, col="blue", outer=TRUE)
box("outer", col="blue")
# To get back to standard par() settings
> op <- par(newsettings)
> ... plots ...
> par(op)
or dev.off()
par()              # view current settings
opar <- par()      # make a copy of current settings
par(col.lab="red") # red x and y labels
hist(mtcars$mpg)   # create a plot with these new settings
par(opar)          # restore original settings
# Further reading:
# http://cran.r-project.org/doc/manuals/R-intro.html#Multiple-figure-environment
# http://cran.r-project.org/doc/manuals/R-intro.html#Multiple-figure-environment
# http://cran.r-project.org/doc/manuals/R-intro.html#Multiple-figure-environment
# http://cran.r-project.org/doc/manuals/R-intro.html#Multiple-figure-environment
MultipleFigures <- function()
{
GenericFigure("1", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("2", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("3", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("4", 3,1)
box("figure", lty="dotted", col="blue")
}
# Figure 3A. Using Multiple Figures.
Figure3A <- function()
{
par(mfrow=c(2,2), mar=c(5.1,4.1,4.1,2.1), oma=c(0,0,0,0))
MultipleFigures()
box("inner", lty="dotted", col="green")
box("outer", lty="solid", col="green")
}
Figure3A
Figure3A()
plot(0:10, 0:10, type="n", xlab="X", ylab="Y")
text(5,5, ID, col="red", cex=size1)
box("plot", col="red") mtext("Figure", SOUTH<-1, line=3, adj=1.0,
cex=size2, col="blue")
box("figure", col="blue")
GenericFigure <- function(ID, size1, size2)
{
plot(0:10, 0:10, type="n", xlab="X", ylab="Y")
text(5,5, ID, col="red", cex=size1)
box("plot", col="red")
mtext("Figure", SOUTH<-1, line=3, adj=1.0, cex=size2, col="blue")
}
MultipleFigures <- function()
{
GenericFigure("1", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("2", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("3", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("4", 3,1)
box("figure", lty="dotted", col="blue")
}
# Figure 3A. Using Multiple Figures.
Figure3A <- function()
}}}
Figure3A
Figure3A()
GenericFigure("1", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("2", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("3", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("4", 3,1)
box("figure", lty="dotted", col="blue")
box("inner", lty="dotted", col="green")
box("outer", lty="solid", col="green")
GenericFigure("1", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("2", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("3", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("4", 3,1)
box("figure", lty="dotted", col="blue")
box("inner", lty="dotted", col="green")
box("outer", lty="solid", col="green")
par(mfrow=c(2,2), mar=c(5.1,4.1,4.1,2.1), oma=c(1,1,1,1))
GenericFigure("1", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("2", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("3", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("4", 3,1)
box("figure", lty="dotted", col="blue")
box("inner", lty="dotted", col="green")
box("outer", lty="solid", col="green")
box("outer", lty="solid", col="black")
par(mfcol=c(2,2), mar=c(4,4,0.5,0.5), oma=c(1.5,2,1,1))
GenericFigure("1", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("2", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("3", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("4", 3,1)
box("figure", lty="dotted", col="blue")
box("inner", lty="dotted", col="green")
mtext("Outer Margin Area",
SOUTH<-1, line=0.2, adj=1.0, cex=1, col="green", outer=TRUE)
mtext("Title Line",
NORTH<-3, line=0, adj=0.5, cex=1.2, col="red", outer=TRUE)
box("outer", lty="solid", col="green")
?mtext
legend(SOUTH,c("hallo"), col = "black", lwd = 3)
legend(SOUTH <- 3,c("hallo"), col = "black", lwd = 3)
legend(SOUTH <- 5,c("hallo"), col = "black", lwd = 3)
legend(NORTH <- 5,c("hallo"), col = "black", lwd = 3)
legend(NORTH <- 1,c("hallo"), col = "black", lwd = 3)
legend(NORTH <- 3,c("hallo"), col = "black", lwd = 3)
legend(WEST <- 1,c("hallo"), col = "black", lwd = 3)
legend(EAST <- 1,c("hallo"), col = "black", lwd = 3)
legend(EAST = 1,c("hallo"), col = "black", lwd = 3)
par(mfrow=c(2,2), mar=c(5.1,4.1,4.1,2.1), oma=c(0,0,0,0))
GenericFigure("1", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("2", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("3", 3,1)
box("figure", lty="dotted", col="blue")
GenericFigure("4", 3,1)
box("figure", lty="dotted", col="blue")
box("inner", lty="dotted", col="green")
box("outer", lty="solid", col="black")
mo <- vector("list",4)
mo
# funktion schreiben fuer die Grundgrafik
# immer gleich:
#* scarcity price
#* achsenbezeichnungen
#* masse der grafik
#* farben
# input parameter, also was sich aendert
#* merit order
#* demand strich
#* auftreffen des preises auf der y-achse (das kann ja auch output sein)
x_standard <- sort(sample(0:500, 20))
y_standard <- c(0,0,4,5,6,8,8,10,10,10,12,12,12,12,15,30,35,37,37,40)
mo <- vector("list", 3)
mo[[1]] <- data.frame(x = x_standard,
y = y_standard)
mo[[2]] <- data.frame(x = 0,
y = 0)
mo[[3]] <- data.frame(x = x_standard[1:15],
y = y_standard[1:15])
demand <- c(-10, 220, 450)
# png("/home/frauke/Documents/renpass/dokumentation/Doktorarbeit/Formatvorlage_thesis/Figures/marginal_scarcity.png")
# input: merit_order with two columns: x and y
#        demand one single value
basicFigure <- function(merit_order,
demand){
plot(merit_order$x,
merit_order$y,
yaxt = "n",
xaxt = "n",
type = "s",
ylim = c(0,500),
xlim = c(-20,500),
ylab = "specific marginal cost [euro/MWh]",
xlab = "offered capacity [MW]")
# straight line of scarcity price
abline(h   = 450,
lty = 3,
lwd = 3,
col = "red")
# demand
abline(v   = demand,
lty = 1,
lwd = 2,
col = "forestgreen")
}
# mfrow with slim outer margin and not so much white space arount the plot
par(mfrow = c(2,2),
mar   = c(4,4,0.5,0.5),
oma   = c(1.5,2,1,1))
basicFigure(merit_order = mo[[1]],
demand      = demand_vector[1])
box("figure", lty="dotted", col="blue")
basicFigure(merit_order = mo[[2]],
demand      = demand_vector[2])
box("figure", lty="dotted", col="blue")
basicFigure(merit_order = mo[[3]],
demand      = demand_vector[3])
box("figure", lty="dotted", col="blue")
basicFigure(merit_order = mo[[1]],
demand      = demand_vector[2])
box("figure", lty="dotted", col="blue")
abline(v   = 0,
lty = 1,
lwd = 2,
col = "black")
rm(list = ls())     # clear objects
graphics.off()      # close graphics windows
# Generate data
x = 0:10;
y = 0:10;
# Plot the data
# - Specify the layout parameters before any plotting
#   If you don't specify them before any plotting, the
#   results will be inconsistent and misaligned.
#
# - oma stands for 'Outer Margin Area', or the total margin space that is outside
#   of the standard plotting region (see graph)
#
# - The vector is ordered, the first value corresponding to the bottom. The entire
#   array is c(bottom, left, top, right)
#
# - All of the alternatives are:
#   - oma: Specify width of margins in number of lines
#   - omi: Specify width of margins in inches
#   - omd: Specify width of margins in 'device coordinates'
#       - Device coordinates place (0,0) in the upper left and (1,1) in the
#         lower right corner
par(oma=c(3,3,3,3))  # all sides have 3 lines of space
#par(omi=c(1,1,1,1)) # alternative, uncomment this and comment the previous line to try
# - The mar command represents the figure margins. The vector is in the same ordering of
#   the oma commands.
#
# - The default size is c(5,4,4,2) + 0.1, (equivalent to c(5.1,4.1,4.1,2.1)).
#
# - The axes tick marks will go in the first line of the left and bottom with the axis
#   label going in the second line.
#
# - The title will fit in the third line on the top of the graph.
#
# - All of the alternatives are:
#   - mar: Specify the margins of the figure in number of lines
#   - mai: Specify the margins of the figure in number of inches
par(mar=c(5,4,4,2) + 0.1)
#par(mai=c(2,1.5,1.5,.5)) # alternative, uncomment this and comment the previous line
# Plot
plot(x, y, type="n", xlab="X", ylab="Y")    # type="n" hides the points
# Place text in the plot and color everything plot-related red
text(5,5, "Plot", col="red", cex=2)
text(5,4, "text(5,5, \"Plot\", col=\"red\", cex=2)", col="red", cex=1)
box("plot", col="red")
# Place text in the margins and label the margins, all in green
mtext("Margins", side=3, line=2, cex=2, col="green")
mtext("par(mar=c(5,4,4,2) + 0.1)", side=3, line=1, cex=1, col="green")
mtext("Line 0", side=3, line=0, adj=1.0, cex=1, col="green")
mtext("Line 1", side=3, line=1, adj=1.0, cex=1, col="green")
mtext("Line 2", side=3, line=2, adj=1.0, cex=1, col="green")
mtext("Line 3", side=3, line=3, adj=1.0, cex=1, col="green")
mtext("Line 0", side=2, line=0, adj=1.0, cex=1, col="green")
mtext("Line 1", side=2, line=1, adj=1.0, cex=1, col="green")
mtext("Line 2", side=2, line=2, adj=1.0, cex=1, col="green")
source('~/Documents/renpass/dokumentation/Doktorarbeit/Formatvorlage_thesis/Figures/code_R_plot_marginal_scarcity.R')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/Documents/renpass/dokumentation/Doktorarbeit/Formatvorlage_thesis/Figures/code_R_plot_marginal_scarcity.R')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/Documents/renpass/dokumentation/Doktorarbeit/Formatvorlage_thesis/Figures/code_R_plot_powercurve.R')
x_on <- power_curve[,1]
y_on <- power_curve[,2]/3
x_on
y_on
x_off <- c(0,2.9,3,4,5,6,7,8,9,10,11,12,13,14,24.99,25,25.01,30)
y_off <- c(0,0,80,238,474,802,1234,1773,2379,2948,3334,3515,3577,3600,3600,0,0,0)
#png("/home/frauke/Documents/renpass/dokumentation/Doktorarbeit/Formatvorlage_thesis/Figures/powercurve_off.png",
power_curve <- data.frame(matrix(c(0,0,
3,25.05,
4,100.29,
5,220.13,
6,408.35,
7,669.29,
8,1010.15,
9,1419.44,
10,1854.26,
11,2207.31,
12,2440.34,
13,2635.23,
14,2831.13,
15,2885.17,
16,2925.7,
17,2986.49,
18,3000,
25,3000,
25.01,0,
30,0),
ncol=2, byrow=TRUE))
x_on <- power_curve[,1]
y_on <- power_curve[,2]/3
# offshore
x_off <- c(0,2.9,3,4,5,6,7,8,9,10,11,12,13,14,24.99,25,25.01,30)
y_off <- c(0,0,80,238,474,802,1234,1773,2379,2948,3334,3515,3577,3600,3600,0,0,0)
#png("/home/frauke/Documents/renpass/dokumentation/Doktorarbeit/Formatvorlage_thesis/Figures/powercurve_off.png",
#    width  = 1600,
#    height = 1000)
plot(x_on,
y/1000,
type = "l",
col = "lightblue",
ylim = c(-0.05,3.1),
#xlim = c(0,27),
xlab = "wind speed at hub height of 90m [m/s]",
ylab = "power output [MW]",
bg = "transparent",
lwd = 1.7,
cex.axis = 3,
cex.lab = 3)
plot(x_on,
y_on/1000,
type = "l",
col = "lightblue",
ylim = c(-0.05,3.1),
#xlim = c(0,27),
xlab = "wind speed at hub height of 90m [m/s]",
ylab = "power output [MW]",
bg = "transparent",
lwd = 1.7,
cex.axis = 3,
cex.lab = 3)
