background preloader

Producing Simple Graphs with R

Producing Simple Graphs with R

Les templates en C++ Introduction Nous allons présenter la notion de template (patron en français). Les templates font parties des grands apports du C++ au langage C. Jusqu'ici on passait en paramètre des fonctions des variables. Avantages On appelle dans ce qui suit symbole indifféremment une fonction, une structure ou une classe. Inconvénients - Comme nous allons le voir par la suite, l'utilisation de template requiert quelques précautions d'usage (typename...) - Le programme est plus long à compiler. Quand utiliser des templates ? L'usage des templates est particulièrement pertinent pour définir des containers, c'est-à-dire des structures qui servent à stocker une collection d'objets (une liste, un vecteur, un graphe...). Les templates sont également adaptés pour définir des algorithmes génériques s'appliquant à une famille de classe. Que dois-je mettre dans les .hpp et dans les .cpp ? Le C++ étant un langage compilé, on ne peut évidemment pas imaginer de compiler pour un symbole donné toutes ses versions.

Data Analysis in the Geosciences 22 January, 2013 Many things are easy in R are simple, but sometimes the solution is not obvious. Adding error bars to a bar plot is one of those things. The segments() command lets you draw line segments, provided you specify the coordinates of the beginning and end of the segments. You could use the locator() function to find the centers of the bars, but clicking on points can be imprecise. Here is how it all works. names <- c("squirrel", "rabbit", "chipmunk") means <- c(23, 28, 19) standardErrors <- c(1.2, 1.7, 0.9) Because the top of the plot is scaled to the tallest bar, the error bars will get clipped if I add them. plotTop <- max(means+standardErrors*2) First, I will plot the graph, with the bars filled with gray, with y-axis labels rotated (las=1), and with the limits on the y-axis expanded so they will include the error bars. barCenters <- barplot(means, names.arg=names, col="gray", las=1, ylim=c(0,plotTop)) Pretty straightforward!

Related: