Dienstag, 17. November 2009

Windows Schriftarten verwenden

Windows Schriftarten müssen definiert werden, bevor sie genutzt werden können:

# Type family examples - creating new mappings
plot(1:10,1:10,type="n")
windowsFonts(
A=windowsFont("Arial Black"),
B=windowsFont("Bookman Old Style"),
C=windowsFont("Comic Sans MS"),
D=windowsFont("Symbol")
)

text(3,3,"Hello World Default")
text(4,4,family="A","Hello World from Arial Black")
text(5,5,family="B","Hello World from Bookman Old Style")
text(6,6,family="C","Hello World from Comic Sans MS")
text(7,7,family="D", "Hello World from Symbol")

Donnerstag, 5. November 2009

Add a time axis


Adding a time scaled x-axis to a plot can be tedious...

# add a time axis
axis(side = 1, at  =as.numeric(seq(as.Date("2000-01-01"), by = "year", length = 10))
  , labels = format( seq(as.Date("2000-01-01"), by = "year", length = 10) , "%Y")
  , cex.axis = 0.8, las = 1)

# plot the timegrid
# vertical gridlines according to chosen time-values
abline(v = seq(as.Date("2000-01-01"), by = "year", length = 10), col = "grey", lty = "dotted")
# where to plot the horizontal gridlines? get the coords by means of axTicks()
abline(h = axTicks(2), col = "grey", lty = "dotted")