[R] Filled step-function?

Beate Kowalczyk beate.kowalczyk at googlemail.com
Wed May 16 13:46:25 CEST 2007


Hi Petr,

polygon doesn't work very well, because I need a graphical display for
the laboratory results of my institute. So I have a lot of data in
.csv-format, and I don't really want to define a new polygon for each
dataset, because then I have to do a lot of extra-work. I need a
solution that works like the following, but with coloring the area under
the function (like the image in my first posting):

labdata <- read.csv("labdata.csv", header=TRUE)
attach(labdata) #for using column-names as variables
plot(variable1,variable2,type="s",main="Title",ylim=c(120,0),xlim=c(0,10))

For each .csv-dataset I want to use this code with only slight
adjustments...

Tanks again, Beate

Petr Klasterecky schrieb:
> Hi,
>
> I am not sure what exactly you would like to fill up and how, but take a 
> look at
> ?polygon
> and the examples given there.
>
> hth
> Petr
>
>
> Beate Kowalczyk napsal(a):
>   
>> Hello,
>>
>> I'd like to generate a filled step-function in R as you can see in the 
>> attachement (image is generated by grapher, but I need a freely 
>> available alternative). The problem is, that I don't know, how to fill 
>> it up. My code right now looks like this:
>>
>> pH <- c(0,6.1,6.1,6.3,6.6,7.3,0)
>> Tiefe <- c(0,0,10,40,80,120,10)
>> plot(pH,Tiefe,type="s",main="Tiefenfunktion pH",ylim=c(120,0),xlim=c(0,23))
>>
>> Can someone give me an hint how to work on this?
>>
>> Thanks, Beate
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> ------------------------------------------------------------------------
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>     
>
>



More information about the R-help mailing list