https://iridia.ulb.ac.be/w/index.php?title=R_and_3D_plots&feed=atom&action=history
R and 3D plots - Revision history
2024-03-28T12:12:00Z
Revision history for this page on the wiki
MediaWiki 1.35.4
https://iridia.ulb.ac.be/w/index.php?title=R_and_3D_plots&diff=1830&oldid=prev
Christensen: /* 3D Plots */
2004-11-22T14:59:52Z
<p><span dir="auto"><span class="autocomment">3D Plots</span></span></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 14:59, 22 November 2004</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 64:</td>
<td colspan="2" class="diff-lineno">Line 64:</td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Use '''help(scatterplot3d)''' to get the full list of parameters and options for the function.</div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Use '''help(scatterplot3d)''' to get the full list of parameters and options for the function.</div></td>
</tr>
<tr>
<td colspan="2" class="diff-empty"> </td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td colspan="2" class="diff-empty"> </td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td colspan="2" class="diff-empty"> </td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>=== 3D and colors ===</div></td>
</tr>
<tr>
<td colspan="2" class="diff-empty"> </td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Replace the '''scatterplot3d''' parameters with the following in order to get (nicer) colorful 3D plots:</div></td>
</tr>
<tr>
<td colspan="2" class="diff-empty"> </td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><pre></div></td>
</tr>
<tr>
<td colspan="2" class="diff-empty"> </td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>scatterplot3d(xyz, highlight.3d=TRUE, col.axis="blue", col.grid="lightblue", main="scatterplot3d", pch=20)</div></td>
</tr>
<tr>
<td colspan="2" class="diff-empty"> </td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></pre></div></td>
</tr>
</table>
Christensen
https://iridia.ulb.ac.be/w/index.php?title=R_and_3D_plots&diff=98&oldid=prev
Christensen: /* 3D Plots */
2004-11-17T19:51:02Z
<p><span dir="auto"><span class="autocomment">3D Plots</span></span></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 19:51, 17 November 2004</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 40:</td>
<td colspan="2" class="diff-lineno">Line 40:</td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></pre></div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></pre></div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td class="diff-marker">−</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">You</del> <del class="diffchange diffchange-inline">can</del> plot the following sequence of commands will do the trick:</div></td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">To</ins> <ins class="diffchange diffchange-inline">do the</ins> plot the following sequence of commands will do the trick:</div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><pre></div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><pre></div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div># R</div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div># R</div></td>
</tr>
</table>
Christensen
https://iridia.ulb.ac.be/w/index.php?title=R_and_3D_plots&diff=97&oldid=prev
Christensen: /* Basics */
2004-11-17T19:50:22Z
<p><span dir="auto"><span class="autocomment">Basics</span></span></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 19:50, 17 November 2004</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 15:</td>
<td colspan="2" class="diff-lineno">Line 15:</td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>'''Show content of a variable''': variable, eg. x </div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>'''Show content of a variable''': variable, eg. x </div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td class="diff-marker">−</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>'''Loading data from a file''': read.table("filename") (assuming that your data file contains data only, where each line describes one point in a multi-dimensional space<del class="diffchange diffchange-inline">, e</del>).</div></td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>'''Loading data from a file''': read.table("filename") (assuming that your data file contains data only, where each line describes one point in a multi-dimensional space).</div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>'''Loading data from a file into a variable''': xyz <- read.table("filename") (you knew that!)</div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>'''Loading data from a file into a variable''': xyz <- read.table("filename") (you knew that!)</div></td>
</tr>
<tr>
<td class="diff-marker">−</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"></td>
<td colspan="2" class="diff-empty"> </td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== 3D Plots ==</div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== 3D Plots ==</div></td>
</tr>
</table>
Christensen
https://iridia.ulb.ac.be/w/index.php?title=R_and_3D_plots&diff=96&oldid=prev
Christensen at 19:49, 17 November 2004
2004-11-17T19:49:38Z
<p></p>
<p><b>New page</b></p><div>[http://www.r-project.org The R Project for Statistical Computing] is a convenient tool for plotting experimental data. If you are using Debian, you can find the R core .deb package, otherwise you can [http://cran.r-project.org/mirrors.html download the R source code] and compile it yourself. <br />
<br />
<br />
== Basics ==<br />
'''Starting R''': Once R is installed you start it by typing R. This will give you an R prompt. <br />
<br />
'''Quitting R''': q()<br />
<br />
'''HTML help''': help.start()<br />
<br />
'''Searching online help''': help.search("what you don't know")<br />
<br />
'''Assignment''': variable <- value, eg. x <- 42<br />
<br />
'''Show content of a variable''': variable, eg. x <br />
<br />
'''Loading data from a file''': read.table("filename") (assuming that your data file contains data only, where each line describes one point in a multi-dimensional space, e).<br />
<br />
'''Loading data from a file into a variable''': xyz <- read.table("filename") (you knew that!)<br />
<br />
<br />
== 3D Plots ==<br />
In order to plot in 3D you need to add a package called ''scatterplot3d'' to R. You should [http://mirrors.sunsite.dk/cran/src/contrib/Descriptions/scatterplot3d.html download scatterplot3d package] from one of the [http://cran.r-project.org/mirrors.html CRAN mirrors] and leave it as a .tar.gz file. Then as root type the following from command-line:<br />
<pre><br />
# R CMD INSTALL scatterplot3D_version.tar.gz<br />
</pre><br />
<br />
Now, to use the package you start R and type:<br />
<pre><br />
> library(scatterplot3d)<br />
</pre><br />
In order to load the package. Hereafter, you can use the function scatterplot3d(). Assume that you have a file in the following format:<br />
<pre><br />
# an example file for 3D plots with R and scatterplot3d<br />
x1 y1 z1<br />
x2 y2 z2<br />
x3 y3 z3<br />
..<br />
..<br />
<br />
</pre><br />
<br />
You can plot the following sequence of commands will do the trick:<br />
<pre><br />
# R<br />
> library(scatterplot3d)<br />
> xyz <- read.table("examplefile.data")<br />
> scatterplot3d(xyz)<br />
> xyz<br />
x1 y1 z1<br />
x2 y2 z2<br />
x3 y3 z3<br />
</pre><br />
<br />
<br />
Assuming everything looks good and you want to save the plot:<br />
<pre><br />
> postscript("greatlookinggraph.eps")<br />
> scatterplot3d(xyz)<br />
> dev.off()<br />
> q()<br />
</pre><br />
<br />
The command '''dev.off()''' turns off the postscript device and flushes unwritten data. There are multiple devices, the default on UNIX is the x11 device, which produces nice windows. A device is started and set to the default graphical output device by simply typing the name of the device followed by brackets. Remember to issue a '''dev.off()''' when you are done with a device. A list of available devices is shown if you type '''help(Devices)''' -- lookout by the way R is '''case-sensitive''' hence, '''help(devices)''' will leave you with nothing but an error message.<br />
<br />
Use '''help(scatterplot3d)''' to get the full list of parameters and options for the function.</div>
Christensen