吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1343|回复: 0
收起左侧

[Python 转载] Plotly入门(一)scatter_application

[复制链接]
hj170520 发表于 2020-6-16 10:35
本帖最后由 hj170520 于 2020-6-16 10:50 编辑

入门代码(一)

scatter_application

# -*- coding: utf-8 -*-

import pandas as pd
import plotly as py
import plotly.graph_objs as pygo

# ----------pre def
pd.set_option('display.width', 450)
pyplt = py.offline.plot
# ----------code
df = pd.read_csv('dat/tk01_m15.csv')
df9 = df[:10]
print(df9)
#
idx = df9['xtim']
xd0 = (df9['close'] - 27) * 50
df2 = df9
df2['xd1'] = xd0 - 10
df2['xd2'] = xd0
df2['xd3'] = xd0 + 10

print('xd2\n', df2)
# --------
xtr1 = pygo.Scatter(
    x=idx,
    y=df2['xd1'],
    mode='markers',  # xtr1,散点图
    name='xtr1-markers'
)
xtr2 = pygo.Scatter(
    x=idx,
    y=df2['xd2'],
    mode='lines',  # xtr2,曲线图
    name='xtr2-lines'
)
xtr3 = pygo.Scatter(
    x=idx,
    y=df2['xd3'],
    mode='markers+lines',  # xtr3,曲线+散点组合
    name='xtr3-markers+lines'
)
xdat = pygo.Data([xtr1, xtr2, xtr3])
layout = pygo.Layout(
    title='收盘价--15分钟分时数据',
    xaxis=pygo.XAxis(tickangle=-15)
)
fig = pygo.Figure(data=xdat, layout=layout)
pyplt(fig,filename=r'tmp\\scatter_apply.html', image='png')

# Because it's going through another layer of interpretation,
# you need to escape the escapes -- essentially, you need to double the backslashes:

# #
print('ok')

plot_image.png



2.3 scatter.zip (4.04 KB, 下载次数: 3)

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-26 03:36

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表