plotly绘制简单图形<10>--金字塔图

为了参照对比,我们一般需要画类似金字塔形状的图表来展示数据,

下面我们那一个例子来看一下效果

import plotly.plotly as py
import plotly.graph_objs as go

import numpy as np

women_bins = np.array([-600, -623, -653, -650, -670, -578, -541, -411, -322, -230])
men_bins = np.array([600, 623, 653, 650, 670, 578, 541, 360, 312, 170])

y = list(range(0, 100, 10))

layout = go.Layout(yaxis=go.layout.YAxis(title='Age'),
                   xaxis=go.layout.XAxis(
                       range=[-1200, 1200],
                       tickvals=[-1000, -700, -300, 0, 300, 700, 1000],
                       ticktext=[1000, 700, 300, 0, 300, 700, 1000],
                       title='Number'),
                   barmode='overlay',
                   bargap=0.1)

data = [go.Bar(y=y,
               x=men_bins,
               orientation='h',#水平条形图需设置,竖直条形图不用设置
               name='Men',
               hoverinfo='x',
               marker=dict(color='#808080')#设置颜色
               ),
        go.Bar(y=y,
               x=women_bins,
               orientation='h',#水平条形图需设置,竖直条形图不用设置
               name='Women',
               text=-1 * women_bins.astype('int'),#women的数据标签
               hoverinfo='text',
               marker=dict(color='seagreen')
               )]

py.iplot(dict(data=data, layout=layout)) 

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
你可以在表格中添加一个自定义的插槽,然后在插槽中使用echarts来绘制表。具体步骤如下: 1. 在表格中添加一个自定义的插槽。例如,在el-table-column中添加一个template属性: ``` <el-table-column label="表"> <template slot-scope="scope"> <div class="chart-container" ref="chartContainer"></div> </template> </el-table-column> ``` 2. 在插槽中使用echarts来绘制表。你需要在插槽所在的组件中引入echarts,并在mounted钩子函数中初始化echarts实例。然后,你可以在插槽中使用这个实例来绘制表。例如: ``` import echarts from 'echarts' export default { data() { return { chartInstance: null } }, mounted() { this.chartInstance = echarts.init(this.$refs.chartContainer) }, methods: { drawChart(data) { // 使用echarts实例绘制表 this.chartInstance.setOption({ // ... }) } } } ``` 3. 在表格的data属性中添加数据,并在插槽中调用drawChart方法来绘制每行不同的表。例如: ``` <el-table :data="tableData"> <!-- ... --> <el-table-column label="表"> <template slot-scope="scope"> <div class="chart-container" ref="chartContainer" @click="drawChart(scope.row.chartData)"></div> </template> </el-table-column> </el-table> ``` 在这个例子中,每行的数据中都包含了一个chartData属性,它是用来绘制表的数据。当用户点击每行的表时,会调用drawChart方法,并传入该行的chartData数据来绘制表。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Andy_shenzl

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值