From a4da92c6dcabd52ab1a10d6ea81814819ed31725 Mon Sep 17 00:00:00 2001 From: michaelbabyn Date: Fri, 9 Nov 2018 09:08:24 -0500 Subject: [PATCH] use matrix for z input instead of vector --- .../r/scientific/2015-07-30-contour-plots.Rmd | 4 ++-- .../r/scientific/2015-07-30-contour-plots.md | 22 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/_posts/r/scientific/2015-07-30-contour-plots.Rmd b/_posts/r/scientific/2015-07-30-contour-plots.Rmd index 3eab378bdaab..8220794eb690 100644 --- a/_posts/r/scientific/2015-07-30-contour-plots.Rmd +++ b/_posts/r/scientific/2015-07-30-contour-plots.Rmd @@ -61,8 +61,8 @@ library(plotly) p <- plot_ly( x = c(-9, -6, -5, -3, -1), y = c(0, 1, 4, 5, 7), - z = c(10, 10.625, 12.5, 15.625, 20, 5.625, 6.25, 8.125, 11.25, 15.625, 2.5, 3.125, 5, 8.125, 12.5, 0.625, 1.25, 3.125, - 6.25, 10.625, 0, 0.625, 2.5, 5.625, 10), + z = matrix(c(10, 10.625, 12.5, 15.625, 20, 5.625, 6.25, 8.125, 11.25, 15.625, 2.5, 3.125, 5, 8.125, 12.5, 0.625, 1.25, 3.125, + 6.25, 10.625, 0, 0.625, 2.5, 5.625, 10), nrow = 5, ncol = 5), type = "contour" ) diff --git a/_posts/r/scientific/2015-07-30-contour-plots.md b/_posts/r/scientific/2015-07-30-contour-plots.md index 80ee6d0d5207..25355cbef264 100644 --- a/_posts/r/scientific/2015-07-30-contour-plots.md +++ b/_posts/r/scientific/2015-07-30-contour-plots.md @@ -34,7 +34,7 @@ packageVersion('plotly') ``` ``` -## [1] '4.7.1' +## [1] '4.8.0' ``` ### Basic Contour @@ -51,7 +51,7 @@ chart_link = api_create(p, filename="contour-basic") chart_link ``` - + ### Set X and Y Coordinates @@ -62,8 +62,8 @@ library(plotly) p <- plot_ly( x = c(-9, -6, -5, -3, -1), y = c(0, 1, 4, 5, 7), - z = c(10, 10.625, 12.5, 15.625, 20, 5.625, 6.25, 8.125, 11.25, 15.625, 2.5, 3.125, 5, 8.125, 12.5, 0.625, 1.25, 3.125, - 6.25, 10.625, 0, 0.625, 2.5, 5.625, 10), + z = matrix(c(10, 10.625, 12.5, 15.625, 20, 5.625, 6.25, 8.125, 11.25, 15.625, 2.5, 3.125, 5, 8.125, 12.5, 0.625, 1.25, 3.125, + 6.25, 10.625, 0, 0.625, 2.5, 5.625, 10), nrow = 5, ncol = 5), type = "contour" ) @@ -73,7 +73,7 @@ chart_link = api_create(p, filename="contour-coordinates") chart_link ``` - + ### Set Size and Range of a Contours @@ -102,7 +102,7 @@ chart_link = api_create(p, filename="contour-range-of-contours") chart_link ``` - + ### Smoothing Contour Lines @@ -150,7 +150,7 @@ chart_link = api_create(p, filename="contour-smoothing-lines") chart_link ``` - + ### Smoothing Contour Coloring @@ -175,7 +175,7 @@ chart_link = api_create(p, filename="contour-smoothing-coloring") chart_link ``` - + ### Add Contour Labels @@ -192,7 +192,7 @@ chart_link = api_create(p, filename="contour-labels") chart_link ``` - + ### Create Matrix and Plot Contour This example is based on (this)[https://www.r-statistics.com/2016/07/using-2d-contour-plots-within-ggplot2-to-visualize-relationships-between-three-variables/] r-statistics post. @@ -232,7 +232,7 @@ chart_link = api_create(p, filename="contour-advanced") chart_link ``` - + ### 2D Density Contour Plot @@ -256,7 +256,7 @@ chart_link = api_create(p, filename="contour-joint") chart_link ``` - + ### Contour Colorscales