{"id":118,"date":"2018-05-01T18:50:12","date_gmt":"2018-05-01T18:50:12","guid":{"rendered":"https:\/\/integrations.pressbooks.network\/oersourcebook\/chapter\/plot-ly-embed\/"},"modified":"2019-12-03T15:10:42","modified_gmt":"2019-12-03T15:10:42","slug":"plot-ly-embed","status":"publish","type":"chapter","link":"https:\/\/integrations.pressbooks.network\/oersourcebook\/chapter\/plot-ly-embed\/","title":{"raw":"Plot.ly Embed","rendered":"Plot.ly Embed"},"content":{"raw":"<h1 style=\"text-align: center;\">Embed Plot.ly Visualizations<\/h1>\nPlot.ly is an <a href=\"https:\/\/plot.ly\/javascript\/open-source-announcement\/\">open-source<\/a>\u00a0visualization tool that allows users who work with R and Python to produce embeddable, interactive graphs to incorporate into web pages. For set-up information, visit \"<a href=\"https:\/\/plot.ly\/r\/getting-started\/\">Getting Started in Plot.ly for R<\/a>\" or \"<a href=\"https:\/\/plot.ly\/python\/getting-started\/\">Getting Started in Plot.ly for Python<\/a>.\"\n\nOnce you have set up your account and produced a visualization, you can use the embed codes that Plot.ly provides. Your source code will include a pair of iframe tags that look like this:\n<div class=\"textbox shaded\">\n<pre>&lt;iframe width=\"900\" height=\"800\" frameborder=\"0\" scrolling=\"no\" src=\"URL HERE\"&gt;&lt;\/iframe&gt;<\/pre>\n<\/div>\nTo put a Plot.ly graph in your book, switch from the 'Visual' to the the 'Text' editor and paste this embed code wherever you'd like the Plot.ly visualization to appear.\n<h2>Change the default width element to allow for dynamic resizing<\/h2>\nOne other thing you can do to improve\u00a0your viewers' reading experience is to remove the \"width\" element in the text. (This will allow the image to adjust to the size of the reader's screen.) Simply change the [ width=\"number\" ] element to width=\"100%\". Using the example above, your embed code would now read:\n<div class=\"textbox shaded\">\n<pre>&lt;iframe <strong>width=\"100%\"<\/strong> height=\"800\" frameborder=\"0\" scrolling=\"no\" src=\"URL HERE\"&gt;&lt;\/iframe&gt;<\/pre>\n<\/div>\n&nbsp;\n<pre class=\"textbox shaded\"><\/pre>\n<iframe src=\"\/\/plot.ly\/~SteelWagstaff\/7.embed\" width=\"100%\" height=\"800\" frameborder=\"0\" scrolling=\"no\"><span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\">\ufeff<\/span><\/iframe>","rendered":"<h1 style=\"text-align: center;\">Embed Plot.ly Visualizations<\/h1>\n<p>Plot.ly is an <a href=\"https:\/\/plot.ly\/javascript\/open-source-announcement\/\">open-source<\/a>\u00a0visualization tool that allows users who work with R and Python to produce embeddable, interactive graphs to incorporate into web pages. For set-up information, visit &#8220;<a href=\"https:\/\/plot.ly\/r\/getting-started\/\">Getting Started in Plot.ly for R<\/a>&#8221; or &#8220;<a href=\"https:\/\/plot.ly\/python\/getting-started\/\">Getting Started in Plot.ly for Python<\/a>.&#8221;<\/p>\n<p>Once you have set up your account and produced a visualization, you can use the embed codes that Plot.ly provides. Your source code will include a pair of iframe tags that look like this:<\/p>\n<div class=\"textbox shaded\">\n<pre>&lt;iframe width=\"900\" height=\"800\" frameborder=\"0\" scrolling=\"no\" src=\"URL HERE\"&gt;&lt;\/iframe&gt;<\/pre>\n<\/div>\n<p>To put a Plot.ly graph in your book, switch from the &#8216;Visual&#8217; to the the &#8216;Text&#8217; editor and paste this embed code wherever you&#8217;d like the Plot.ly visualization to appear.<\/p>\n<h2>Change the default width element to allow for dynamic resizing<\/h2>\n<p>One other thing you can do to improve\u00a0your viewers&#8217; reading experience is to remove the &#8220;width&#8221; element in the text. (This will allow the image to adjust to the size of the reader&#8217;s screen.) Simply change the [ width=&#8221;number&#8221; ] element to width=&#8221;100%&#8221;. Using the example above, your embed code would now read:<\/p>\n<div class=\"textbox shaded\">\n<pre>&lt;iframe <strong>width=\"100%\"<\/strong> height=\"800\" frameborder=\"0\" scrolling=\"no\" src=\"URL HERE\"&gt;&lt;\/iframe&gt;<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<pre class=\"textbox shaded\"><\/pre>\n<p><iframe loading=\"lazy\" src=\"\/\/plot.ly\/~SteelWagstaff\/7.embed\" width=\"100%\" height=\"800\" frameborder=\"0\" scrolling=\"no\"><span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\">\ufeff<\/span><\/iframe><\/p>\n","protected":false},"author":14,"menu_order":2,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[],"contributor":[],"license":[],"class_list":["post-118","chapter","type-chapter","status-publish","hentry"],"part":114,"_links":{"self":[{"href":"https:\/\/integrations.pressbooks.network\/oersourcebook\/wp-json\/pressbooks\/v2\/chapters\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/integrations.pressbooks.network\/oersourcebook\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/integrations.pressbooks.network\/oersourcebook\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/integrations.pressbooks.network\/oersourcebook\/wp-json\/wp\/v2\/users\/14"}],"version-history":[{"count":1,"href":"https:\/\/integrations.pressbooks.network\/oersourcebook\/wp-json\/pressbooks\/v2\/chapters\/118\/revisions"}],"predecessor-version":[{"id":119,"href":"https:\/\/integrations.pressbooks.network\/oersourcebook\/wp-json\/pressbooks\/v2\/chapters\/118\/revisions\/119"}],"part":[{"href":"https:\/\/integrations.pressbooks.network\/oersourcebook\/wp-json\/pressbooks\/v2\/parts\/114"}],"metadata":[{"href":"https:\/\/integrations.pressbooks.network\/oersourcebook\/wp-json\/pressbooks\/v2\/chapters\/118\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/integrations.pressbooks.network\/oersourcebook\/wp-json\/wp\/v2\/media?parent=118"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/integrations.pressbooks.network\/oersourcebook\/wp-json\/pressbooks\/v2\/chapter-type?post=118"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/integrations.pressbooks.network\/oersourcebook\/wp-json\/wp\/v2\/contributor?post=118"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/integrations.pressbooks.network\/oersourcebook\/wp-json\/wp\/v2\/license?post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}