plotly python

I recently worked with Plotly for data visualization on predicted outputs coming from a Machine Learning Model.

我最近与Plotly合作,对来自机器学习模型的预测输出进行数据可视化。

The documentation I referred to : https://plotly.com/python/

我提到的文档: https : //plotly.com/python/

Here are few “google searches” I personally did while I was working on it:

以下是我在进行搜索时亲自进行的“ google搜索”:

Question : Which data viz library should I choose for interactive plots?Answer : Matplotlib, Seaborn, Plotly, Altair, and Bokeh were some of the answers. The reason I went with Plotly was because my project requirement was to get charts on a html page which is supported by Plotly. With Plotly, the charts are stored as .html files and can be zoomed in, zoomed out and also focused on a particular region.

问:我应该为交互式绘图选择哪个数据视图库?答案: Matplotlib,Seaborn,Plotly,Altair和Bokeh是其中的一些答案。 我选择Plotly的原因是因为我的项目要求是在Plotly支持的html页面上获取图表。 使用Plotly,可以将图表存储为.html文件,并且可以放大,缩小并且还可以将焦点放在特定区域上。

Question: Plotly Express or Plotly Graph Objects Answer : I started with Plotly Express but ended up using Plotly Graph Objects for the very reason that it provided me a lot of modifications to my existing code. There were more number of attributes which could provide better cosmetic changes to the charts.

问题:Plotly Express或Plotly Graph对象 回答:我从Plotly Express开始,但最终由于使用Plotly Graph Objects而对我的现有代码进行了大量修改,因此最终使用了Plotly Graph Objects。 有更多的属性可以为图表提供更好的外观更改。

关于图形对象 (In terms of Plotly Graph Objects)

import plotly.graph_objs as go

将go导入plotly.graph_objs

Question: How do I show two columns from my data set against time?Answer : choose your “mode” as lines and lines + markers.mode = ‘lines’ , can be set when you add your trace.

问题:如何显示数据集中随时间变化的两列? 答案:选择“模式”作为线和线+标记。mode='lines',可以在添加迹线时设置。

fig = go.Figure()fig.add_trace(go.Scatter(x=data[‘time’],y=data[‘Values_x’],mode=‘lines’))fig.add_trace(go.Scatter(x=data[‘time’],y=data[‘Values_y’],mode=‘lines+markers’))

fig = go.Figure()fig.add_trace(go.Scatter(x = data ['time'],y = data ['Values_x'],mode ='lines'))fig.add_trace(go.Scatter(x = data ['time'],y = data ['Values_y'],mode ='lines + marks'))

Question: What else I can add in my go.Scatter() function to modify my data points?Answer: Other attributes which can be used to modify the plots can be name : name of the data point which is being plotted, string valueshowlegend : If the legend should be visible or not, Boolean value with True or Falsemarker_color : if your mode is lines+markers or just markers you can give a specific color to it, it accepts RGBA, RGB, HSL, or a name of the color in a string valueline_width : determines the width of the line in your plot, accepts an int value line_color : the color of the linefont : one can choose the font from the font family available in plotly.

问题:我还可以在go.Scatter()函数中添加哪些内容来修改数据点? 答:其他可用于修改图的属性可以是name :要绘制的数据点的名称,字符串值showlegend :如果图例不可见,则布尔值为True或False marker_color :如果您的模式是线条+标记或只是标记,您可以为其指定特定的颜色,可以接受RGBA,RGB,HSL或字符串值中的颜色名称line_width :确定绘图中线条的宽度,接受一个int值line_color :线条字体的颜色:可以从可用的字体家族中选择字体。

Question: Once I choose my font family, how do I choose the font color and its size?Answer: Many attributes in plotly have an option of specifying a dict and further writing a key value pair in it.

问:选择字体系列后,如何选择字体颜色和字体大小?答案 :plotly中的许多属性都可以选择指定dict并在其中进一步编写键值对。

font=dict(family=’Times New Roman’,size=16,color=’red’)

font = dict(family ='Times New Roman',size = 16,color ='red')

Question: How do I put a hover label on my plots?Answer : Hover labels are kind of boxes which are visible when you move your cursor to a specific data point. They help the user in understanding the value and other details in your chart.

问:如何在图形上放置一个悬停标签?答案:悬停标签是将光标移到特定数据点时可见的一种框。 它们帮助用户了解图表中的值和其他详细信息。

hoverlabel=dict(bgcolor=’lightblue’,font=dict(family=’Times New Roman’,size=16),bordercolor=’black’),hovertemplate=’Booth Humidity<br>Probability: %{y}’)

hoverlabel = dict(bgcolor ='lightblue',font = dict(family ='Times New Roman',size = 16),bordercolor ='black'),hovertemplate ='Booth Humidity <br> Probability:%{y}')

bgcolor is the back ground color of the hover boxhovertemplate will contain basic html tags, it can be altered according to the style one wants to keep.

bgcolor是悬停框的背景hovertemplate将包含基本的html标签,可以根据您想要保留的样式进行更改。

Question: How do I make subplots in plotly?Answer: There are various kinds of subplots which we can make on plotly by specifying the number of rows and columns.

问题:我如何进行子图绘制? 答:通过指定行数和列数,可以在图上进行多种子图绘制。

fig.make_subplots(rows=3,column=1,vertical_spacing=0.5,horizontal_spacing=0.5)

fig.make_subplots(行= 3,列= 1,垂直间距= 0.5,水平间距= 0.5)

This will give you 3 subplots stacked together. It can be varied accordingly. Vertical spacing indicates the distance between the columns of the subplots specified whereas the Horizontal Spacing is between two rows of the subplots.

这将使您将3个子图堆叠在一起。 它可以相应地变化。 垂直间距表示指定的子图的各列之间的距离,而水平间距表示子图的两行之间。

Simply specify row and column number in each go.Scatter function. This way you can also keep multiple data points in the same subplot. (i.e two or more go.Scatter can have same row number and column number)

只需在每个go.Scatter函数中指定行号和列号。 这样,您还可以将多个数据点保留在同一子图中。 (即两个或多个go.Scatter可以具有相同的行号和列号)

Question: How do I make one subplot to be larger in size than my other two subplots?Answer: There is a very useful parameter called “specs” which is basically a 2D list inside the make_subplots() function where one can specify the colspan, rowspan or None. None indicates that no subplot will be drawn in that dimension and hence that is where your larger sized subplot goes.

问题:如何使一个子图的尺寸大于其他两个子图的尺寸? 答:有一个非常有用的参数称为“ specs” ,它基本上是make_subplots()函数中的2D列表,可以在其中指定colspan,rowspan或None。 None表示不会在该维度上绘制子图,因此这是您较大尺寸的子图所在的位置。

Question: Can I make a subplot with common axis?Answer: Plotly has a provision of making subplots with shared (common) xaxis and yaxis. shared_xaxes or shared_yaxes has to be set to true in the make_subplots() function

问题:我可以制作一个具有公共轴的子图吗? 答: Plotly提供了使用共享(公用)xaxis和yaxis制作子图的条件。 必须在make_subplots()函数中将shared_xaxes或shared_yaxes设置为true

Question: How do I give different xaxis title or yaxis title to each subplot?Answer: you can specify the axis title with the subplot number in the update_layout() function.

问题:如何给每个子图赋予不同的xaxis标题或yaxis标题? 答:您可以在update_layout()函数中用子图号指定轴标题。

Example- for subplot in the row 2 has the yaxis titled as yaxis2_title

示例-第2行中的子图的yaxis标题为yaxis2_title

Question: What is update_layout and what all attributes it holds?Answer: update_layout is the overall function to make the plot look presentable. One can specify the following in it:height : Height of the chartwidth : Width of the charttitle: The overall title of your chartshowgrid: the horizontal and vertical gridlines present in your chart plot_bgcolor: the color inside the plot paper_bgcolor: the color where the plot is present

问题:什么是update_layout?它具有什么所有属性? 答: update_layout是使绘图看起来更美观的整体功能。 一个可以指定在它下面的: 高度:图表宽度的高度图表标题的宽度图表showgrid的整体标题水平和垂直网格线存在于图表plot_bgcolor:颜色的情节paper_bgcolor颜色情节所在的地方

Question: Does Plotly have individual functions to update xaxis and yaxis?Answer: It indeed does, update_xaxes and update_yaxes has attributes like showgrid, title_font, etc which can be modified as per the requirements.

问题:Plotly是否有单独的功能来更新xaxis和yaxis? 答:的确如此, update_xaxes和update_yaxes具有诸如showgrid,title_font等属性,可以根据要求进行修改。

Question: Can we give names to each subplot?Answers: Each subplot can be given a title by the attribute subplot_titles present in the make_subplots() function.

问题:我们可以给每个子图命名吗? 答案:每个子图都可以通过make_subplots()函数中存在的属性subplot_titles来获得标题。

I have also used the other functionalities like a Range Slider and buttons in Plotly which I will be discussing in my next article very soon!

我还使用了其他功能,例如范围滑块和 Plotly中的按钮 ,这些功能我将在下一篇文章中很快讨论!

This was the first time I touched upon Data Visualization using Python. I have also written few other articles on Data Viz using tools like PowerBI which can be found here

这是我第一次使用Python进行数据可视化。 我还使用PowerBI之类的工具在Data Viz上写了其他文章,可以在这里找到

I have also developed an alerting system app using PowerApps and written an article about an awesome function I used there to integrate it with my PowerBI reports. Do check that out too here.

我还使用PowerApps开发了一个警报系统应用程序,并写了一篇文章,介绍了我在其中使用过的强大功能将其与PowerBI报告集成在一起。 这里也要检查一下 。

Let me know if you have any queries or suggestions regarding this by commenting below or reach me out on Twitter for any fun discussions revolving around Data Viz or Pandas! :)

如果您对此有任何疑问或建议,请在下面评论中告诉我,或者在Twitter上与我联系,以获取有关Data Viz或Pandas的有趣讨论! :)

翻译自: https://medium.com/analytics-vidhya/basic-thoughts-while-working-with-plotly-for-python-3721d160303c

plotly python


http://www.taodudu.cc/news/show-997608.html

相关文章:

  • java项目经验行业_行业研究以及如何炫耀您的项目
  • 数据科学 python_适用于数据科学的Python vs(和)R
  • r怎么对两组数据统计检验_数据科学中最常用的统计检验是什么
  • 深度学习概述_深度感测框架概述
  • 为什么即使在班级均衡的情况下,准确度仍然令人困扰
  • 接受拒绝算法_通过算法拒绝大学学位
  • 为什么用scrum_为什么Scrum糟糕于数据科学
  • 使用集合映射和关联关系映射_使用R进行基因ID映射
  • 详尽kmp_详尽的分步指南,用于数据准备
  • SMSSMS垃圾邮件检测器的专业攻击
  • 使用Python进行地理编码和反向地理编码
  • grafana 创建仪表盘_创建仪表盘前要问的三个问题
  • 大数据对社交媒体的影响_数据如何影响媒体,广告和娱乐职业
  • python 装饰器装饰类_5分钟的Python装饰器指南
  • 机器学习实际应用_机器学习的实际好处是什么?
  • mysql 时间推移_随着时间的推移可视化COVID-19新案例
  • 海量数据寻找最频繁的数据_寻找数据科学家的“原因”
  • kaggle比赛数据_表格数据二进制分类:来自5个Kaggle比赛的所有技巧和窍门
  • netflix_Netflix的Polynote
  • 气流与路易吉,阿戈,MLFlow,KubeFlow
  • 顶级数据恢复_顶级R数据科学图书馆
  • 大数据 notebook_Dockerless Notebook:数据科学期待已久的未来
  • 微软大数据_我对Microsoft的数据科学采访
  • 如何击败腾讯_击败股市
  • 如何将Jupyter Notebook连接到远程Spark集群并每天运行Spark作业?
  • twitter 数据集处理_Twitter数据清理和数据科学预处理
  • 使用管道符组合使用命令_如何使用管道的魔力
  • 2020年十大币预测_2020年十大商业智能工具
  • 为什么我们需要使用Pandas新字符串Dtype代替文本数据对象
  • nlp构建_使用NLP构建自杀性推文分类器

plotly python_使用Plotly for Python时的基本思路相关推荐

  1. 正则 负数 python_【记录】Python推特爬虫思路

    1.爬虫脚本Listener.py 设计为24/7运行,但可能因为不明原因停止运行,所以需要另写一个脚本用来check运行状态,如果发现爬虫停了就让它重启.可以用python的 os.system() ...

  2. R语言plotly可视化:plotly可视化分组归一化直方图(historgram)并在直方图中添加密度曲线kde、并在直方图的底部部边缘使用geom_rug函数添加边缘轴须图

    R语言plotly可视化:plotly可视化分组归一化直方图(historgram)并在直方图中添加密度曲线kde.并在直方图的底部部边缘使用geom_rug函数添加边缘轴须图Marginal rug ...

  3. R语言plotly可视化:plotly可视化箱图、相同数据集对比使用不同分位数算法的可视化差异(quartilemethod参数、linear、inclusive、exclusive)

    R语言plotly可视化:plotly可视化箱图.相同数据集对比使用不同分位数算法的可视化差异(quartilemethod参数.linear.inclusive.exclusive) 目录

  4. R语言plotly可视化:plotly可视化分裂的分组小提琴图、每个小提琴图内部分为两组数据、每个分组占小提琴图的一半(Split violin plot in R with plotly)

    R语言plotly可视化:plotly可视化分裂的分组小提琴图.每个小提琴图内部分为两组数据.每个分组占小提琴图的一半(Split violin plot in R with plotly) 目录

  5. R语言plotly可视化:plotly可视化箱图、基于预先计算好的分位数、均值、中位数等统计指标可视化箱图、箱图中添加缺口、可视化均值和标准差(With Precomputed Quartiles)

    R语言plotly可视化:plotly可视化箱图.基于预先计算好的分位数.均值.中位数等统计指标可视化箱图.箱图中添加缺口.可视化均值和标准差(Box Plot With Precomputed Qu ...

  6. R语言plotly可视化:plotly可视化多个直方图、通过bingroup参数设置多个直方图使用相同的bins设置(Share bins between histograms)

    R语言plotly可视化:plotly可视化多个直方图.通过bingroup参数设置多个直方图使用相同的bins设置(Share bins between histograms) 目录

  7. R语言plotly可视化:plotly可视化累积cumulative直方图(Cumulative Histogram)

    R语言plotly可视化:plotly可视化累积cumulative直方图(Cumulative Histogram) 目录 R语言plotly可视化:plotly可视化累积cumulative直方图 ...

  8. R语言plotly可视化:plotly可视化水平直方图(Horizontal Histogram)

    R语言plotly可视化:plotly可视化水平直方图(Horizontal Histogram) 目录 R语言plotly可视化:plotly可视化水平直方图(Horizontal Histogra ...

  9. R语言plotly可视化:plotly可视化在散点图中添加误差条(Scatterplot with Error Bars with plotly in R)

    R语言plotly可视化:plotly可视化在散点图中添加误差条(Scatterplot with Error Bars with plotly in R) 目录 R语言

最新文章

  1. linux 进程 内存 换入换出,linux - 在从bash进程替换完成输入后,如何继续发送到stdin? - 堆栈内存溢出...
  2. 获得诺贝尔奖的底层小职员 | 从来没有一个高手,是在一夜之间强大起来的
  3. java repaint_java repaint()无效
  4. Citrix Xendesktop中VDA注册DDC的流程
  5. 项目集跟进计划_项目延期,项目经理应该如何补救?
  6. 鸿蒙大陆武器合成,鸿蒙大陆9.1攻略(附隐藏英雄密码)
  7. python小猪蹄儿
  8. Clojure 学习
  9. 北航计算机和上财金融,这所985财经学府,不招本科生,隐藏实力却已超过上财、央财?...
  10. java移动接口发短信_天天都会写接口(interface),但它的用途和好处有多少人能说得清楚?
  11. centos7 mysql启动后端口_centos7 修改mysql5.7默认端口后启动异常
  12. HTML <input> required 属性
  13. 面面俱到的Java接口自动化测试实战
  14. java的IO操作之--RandomAccessFile
  15. 云网融合个人学习--云网融合典型场景分析【摘抄】
  16. 当代研究生精神状态:早c晚a?!
  17. hbase 问题之 File system needs to be upgraded. You have version null and I want ver
  18. 绕过CDN查找真实IP方法
  19. 第1章第17节:如何使用备注功能对内容进行注释补充 [PowerPoint精美幻灯片实战教程]
  20. Context Contrasted Feature and Gated Multi-scale Aggregation for Scene Segmentation

热门文章

  1. 基于TCP的在线聊天程序
  2. Coding Interview Guide -- 向有序的环形单链表中插入新节点
  3. Ubuntu 装机软件
  4. Mina、Netty、Twisted一起学(五):整合protobuf
  5. ibatis 中 $与#的区别
  6. hdu 2048 神、上帝以及老天爷
  7. 感染EXE文件代码(C++)
  8. 洛谷P1605:迷宫(DFS)
  9. 浅谈 JDBC 中 CreateStatement 和 PrepareStatement 的区别与优劣。
  10. [解读REST] 3.基于网络应用的架构