plotly django_使用Plotly為Django HTML頁面進行漂亮的可視化

plotly django

Hello everyone! Recently I had to do some visualizations for my university project, I’ve done some googling and haven’t found any simple guides on how to put Plotly plots on an HTML page.

大家好! 最近,我不得不為我的大學項目做一些可視化處理,做了一些谷歌搜索,還沒有找到任何有關如何在HTML頁面上放置Plotly圖的簡單指南。

Before we start I assume that you have running the Django HTML page. Why Plotly? Plotly allows you to make interactive, beautifully designed plots in a matter of minutes. Despite that originally Plotly is a Python library, we won’t use any Python programming today.

在開始之前,我假設您已經運行了Django HTML頁面。 為什么情節? 通過Plotly,您可以在幾分鐘內完成交互式 ,設計精美的繪圖。 盡管Plotly最初是一個Python庫,但今天我們不會使用任何Python編程。

對于那些沒有太多時間的人,這里是簡短指南: (For those who don’t have much time, here is the short guide:)

  • Go to Plotly Chart Studio, create your account.

    轉到Plotly Chart Studio ,創建您的帳戶。

  • Click on the “Create” button and choose “Chart”.

    單擊“創建”按鈕,然后選擇“圖表”。
  • Import your data and click on the “Trace” button.

    導入數據,然后單擊“跟蹤”按鈕。
  • Choose the type of plot you want.

    選擇所需的繪圖類型。
  • Once you made your dream-plot, save it, setting all the settings to “Public”.

    完成夢境圖后,將其保存,將所有設置都設置為“公共”。
  • Share your plot, by copying iframe code from the “Embed” tab and past it to the body of your HTML page.

    通過從“嵌入”標簽復制iframe代碼并將其粘貼到HTML頁面的正文中,共享繪圖。

Now for those who have time, let’s see in detail how we can get the same result, as you saw at the beginning.

現在,對于那些有時間的人,讓我們詳細了解如何獲得與您一開始看到的結果相同的結果。

步驟1.創建一個帳戶并上傳數據。 (Step 1. Creating an account and uploading the data.)

Image for post
Image by Author
圖片作者

We will use Plotly Chart Studio. Once you’ve signed up, you’ll see “Create” in the upper-right corner.

我們將使用Plotly Chart Studio 。 注冊后,您會在右上角看到“創建”。

To create our visualizations we have to import our data first. The data can be either CSV, single-sheet Excel file, link to a CSV file or the data got using SQL and Falcon SQL client.

要創建可視化,我們必須首先導入數據。 數據可以是CSV,單頁Excel文件,鏈接到CSV文件或使用SQL和Falcon SQL客戶端獲取的數據。

Once you uploaded your data, you’ll see it in the table (red square) on the top of your screen.

上傳數據后,您會在屏幕頂部的表格(紅色正方形)中看到該數據。

Image for post
Plotly Studio, Image by Author
Plotly Studio,作者提供的圖片

步驟2.選擇圖的類型并跟蹤數據。 (Step 2. Choosing the type of plot and tracing the data.)

Now let’s look at the blue square on the picture and trace some data.

現在,讓我們看一下圖片上的藍色方塊并跟蹤一些數據。

Image for post
Image by Author
圖片作者

You can choose between different types of plots. Here I chose the Choropleth Atlas Map since it allows me to get this nice Earth visualization.

您可以在不同類型的圖之間進行選擇。 在這里,我選擇了Choropleth Atlas地圖,因為它可以使我獲得很好的地球可視化效果。

步驟3.指定位置和值。 (Step 3. Specifying location and values.)

Then you have to specify columns that will be used as locations and values. You also have to choose the location format, since it can be countries’ names or abbreviations and so on.

然后,您必須指定將用作位置和值的列。 您還必須選擇位置格式,因為它可以是國家或地區的名稱或縮寫等。

Image for post
Image by Author
圖片作者

Here you can see all my settings, which you can use to get the same result as mine.

在這里,您可以看到我的所有設置,可以用來獲得與我相同的結果。

步驟4.保存和共享圖。 (Step 4. Saving and sharing the plot.)

Image for post
Image by Author
圖片作者

We are almost there! Click the “Save” button and choose “Public” for Plot and Grid.

我們就快到了! 單擊“保存”按鈕,然后為“圖和網格”選擇“公共”。

Image for post
Image by Author
圖片作者

Finally, you click the “Share” button, choose “Embed” and copy iframe HTML code, which you can pass in the body of your HTML page.

最后,您點擊“共享”按鈕,選擇“嵌入”并復制iframe HTML代碼,您可以將其傳遞到HTML頁面的正文中。

Thank you for reading!

感謝您的閱讀!

翻譯自: https://towardsdatascience.com/making-beautiful-visualizations-for-a-django-html-page-using-plotly-f4e97d3f6bc7

plotly django

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/389106.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/389106.shtml
英文地址,請注明出處:http://en.pswp.cn/news/389106.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

roce和iwarp_VIA、IB、RDMA、RoCE、iWARP、DPDK的發展與糾纏?

VIA(Virtual Interface Architecture): 這個只是一個標準,基本上不要了解太多。樓主的問題可以細分成2個層次考慮。一個是網絡環境,二是具體的協議和實現。一、網絡環境IB(InfiniBand): 是一種網絡環境,做對比的是以太網, IB往往用于高性能集…

remoting

原文地址:http://blog.csdn.net/chengking/archive/2005/10/26/517349.aspx (一).說明 一個遠程調用示例. 此示例實現功能: 客房端調用遠程方法(遠程方法可以彈 出自定義信息),實現發送信息功能. 實現原理概是這樣的…

handler 消息處理機制

關于handler消息處理機制,只要一提到,相信作為一個android工程師,腦海就會有這么一個流程 大家都滾瓜爛熟了,但別人問到幾個問題,很多人還是栽到這個“爛”上面,比如: 一個線程是如何對應一個L…

es6簡單介紹

let和const 原先聲明變量的形式 var test 5; //全局變量 function a() {var cc3; //局部變量alert(test); } function b(){alert(test);}test 5;//全局變量 function a() {aa3; //全局變量alert(test); } 在es6之前,作用域只有全局作用域和函數作用域&#xff0…

軟件工程方法學要素含義_日期時間數據的要素工程

軟件工程方法學要素含義According to Wikipedia, feature engineering refers to the process of using domain knowledge to extract features from raw data via data mining techniques. These features can then be used to improve the performance of machine learning a…

洛谷P1605:迷宮(DFS)

題目背景 迷宮 【問題描述】 給定一個N*M方格的迷宮,迷宮里有T處障礙,障礙處不可通過。給定起點坐標和終點坐標,問: 每個方格最多經過1次,有多少種從起點坐標到終點坐標的方案。在迷宮中移動有上下左右四種方式,每次只…

vue圖片壓縮不失真_圖片壓縮會失真?快試試這幾個無損壓縮神器。

前端通常在做網頁的時候 會出現圖片加載慢的情況 在這里我通常會將圖片進行壓縮 但是通常情況下 觀眾會認為 圖片壓縮會出現失真的現象 在這里我會向大家推薦幾款圖片壓縮的工具 基本上會實現無損壓縮1.TinyPng地址:https://tinypng.comEnglish?不要慌&a…

remoteing2

此示例主要演示了net remoting,其中包含一個服務器程序Server.exe和一個客戶端程序CAOClient.exe。客戶端程序會通過http channel調用服務器端RemoteType.dll的對象和方法。服務器端的代碼文件由下圖所述:Server.cs源代碼 :using System;using System.Runtime.Remot…

android 線程池

為什么用線程池 創建/銷毀線程伴隨著系統開銷,過于頻繁的創建/銷毀線程,會很大程度上影響處理效率 例如: 記創建線程消耗時間T1,執行任務消耗時間T2,銷毀線程消耗時間T3 如果T1T3>T2,那么是不是說開…

datatable轉化泛型

public class ConvertHelper<T>where T:new() { /// <summary> /// 利用反射和泛型 /// </summary> /// <param name"dt"></param> /// <returns></returns> public static List<T> ConvertToList(DataTable dt) { …

【躍遷之路】【651天】程序員高效學習方法論探索系列(實驗階段408-2018.11.24)...

(收集箱&#xff08;每日一記&#xff0c;每周六整理&#xff09;)專欄 實驗說明 從2017.10.6起&#xff0c;開啟這個系列&#xff0c;目標只有一個&#xff1a;探索新的學習方法&#xff0c;實現躍遷式成長實驗期2年&#xff08;2017.10.06 - 2019.10.06&#xff09;我將以自己…

更換mysql_Docker搭建MySQL主從復制

Docker搭建MySQL主從復制 主從服務器上分別安裝Docker 1.1 Docker 要求 CentOS 系統的內核版本高于 3.10 [rootlocalhost ~]# uname -r 3.10.0-693.el7.x86_641.2 確保 yum 包更新到最新。 [rootlocalhost ~]# sudo yum update Loaded plugins: fastestmirror, langpacks Loadi…

dll文件的c++制作dll文件的c++制作

dll文件的c制作1、首先用vs2005建立一個c的dll動態鏈接庫文件&#xff0c;這時&#xff0c;// DllTest.cpp : 定義 DLL 應用程序的入口點。//#include "stdafx.h"//#include "DllTest.h"#ifdef _MANAGED#pragma managed(push, off)#endifBOOL APIENTRY Dll…

理解ConstraintLayout 對性能的好處

自從在17年GoogleI/O大會宣布了Constraintlayout,我們持續提升了布局的穩定性和布局編輯的支持。我們還為ConstraintLayout添加了一些新特性支持創建不同類型的布局&#xff0c;添加這些新特性&#xff0c;可以明顯的提升性能&#xff0c;在這里&#xff0c;我門將討論Contrain…

數據湖 data lake_在Data Lake中高效更新TB級數據的模式

數據湖 data lakeGOAL: This post discusses SQL “UPDATE” statement equivalent for a data lake (object) storage using Apache Spark execution engine. To further clarify consider this, when you need to perform conditional updates to a massive table in a relat…

如何理解運維

運維工程師&#xff08;運營&#xff09;&#xff0c;負責維護并確保整個服務的高可用性&#xff0c;同時不斷優化系統架構提升部署效率&#xff0c;優化資源利用率提高整體的投資回報率。運維工程師面對的最大挑戰是大規模集群的管理問題&#xff0c;如何管理好幾十萬臺服務器…

advanced installer更換程序id_好程序員web前端培訓分享kbone高級-事件系統

好程序員web前端培訓分享kbone高級-事件系統&#xff1a;1、用法&#xff0c;對于多頁面的應用&#xff0c;在 Web 端可以直接通過 a 標簽或者 location 對象進行跳轉&#xff0c;但是在小程序中則行不通&#xff1b;同時 Web 端的頁面 url 實現和小程序頁面路由也是完全不一樣…

ai對話機器人實現方案_顯然地引入了AI —無代碼機器學習解決方案

ai對話機器人實現方案A couple of folks from Obviously.ai contacted me a few days back to introduce their service — a completely no-code machine learning automation tool. I was a bit skeptical at first, as I always am with supposedly fully-automated solutio…

網絡負載平衡的

網絡負載平衡允許你將傳入的請求傳播到最多達32臺的服務器上&#xff0c;即可以使用最多32臺服務器共同分擔對外的網絡請求服務。網絡負載平衡技術保證即使是在負載很重的情況下它們也能作出快速響應。 網絡負載平衡對外只須提供一個IP地址&#xff08;或域名&#xff09;。 如…

透明狀態欄導致windowSoftInputMode:adjustResize失效問題

當我們通過下面代碼&#xff1a; getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); 設置狀態欄透明&#xff0c;當界面存在EditText時&#xff0c;在activity里面設置windowSoftInputMode:…