标题:画散点图,怎么调节图中 曲线 的粗细
只看楼主
frefly0203
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2021-1-9
结帖率:0
 问题点数:0 回复次数:2 
画散点图,怎么调节图中 曲线 的粗细
import xlrd
import os
from openpyxl import Workbook
from openpyxl.chart import (
    ScatterChart,
    Reference,
    Series,
    )



            chart = ScatterChart()#散点图
 
            chart.title = list_1[0][n]
            chart.style = 13
            chart.linewidths=1


代码如上,想在excel中画散点图,请问 曲线 的粗细能调节, 使用什么命令,谢谢各位!!!!!!!!!!!!!
搜索更多相关主题的帖子: chart excel 曲线 import from 
2021-06-09 20:45
fall_bernana
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:17
帖 子:240
专家分:2086
注 册:2019-8-16
得分:0 
回复 楼主 frefly0203
程序代码:
from openpyxl import Workbook
from openpyxl.chart import (
    ScatterChart,
    Reference,
    Series,
)
wb = Workbook()
ws = wb.active
rows = [
    ['Size', 'Batch 1', 'Batch 2'],
    [2, 40, 30],
    [3, 40, 25],
    [4, 50, 30],
    [5, 30, 25],
    [6, 25, 35],
    [7, 20, 40],
]
for row in rows:
    ws.append(row)
chart = ScatterChart()
chart.title = "Scatter Chart"
chart.style = 10
chart.x_axis.title = 'Size'
chart.y_axis.title = 'Percentage'
xvalues = Reference(ws, min_col=1, min_row=2, max_row=7)
for i in range(2, 4):
    values = Reference(ws, min_col=i, min_row=1, max_row=7)
    series = Series(values, xvalues, title_from_data=True)
    chart.series.append(series)
# 第一条散点
s1 = chart.series[0]
# 散点标记类型  'auto', 'dash', 'triangle', 'square', 'picture', 'circle', 'dot', 'plus', 'star', 'diamond', 'x'
s1.marker.symbol = "circle"
s1.marker.graphicalProperties.solidFill = "0000FF"  # Marker filling 设定标记填充的颜色
s1.marker.graphicalProperties.line.solidFill = "0000FF"  # Marker outline 标记轮廓的颜色
s1.graphicalProperties.line.noFill = True  # 关闭连线填充
# 第二条带连线的散点
s2 = chart.series[1]
s2.marker.symbol = "circle"
s2.graphicalProperties.solidFill = "FF0000"
s2.marker.graphicalProperties.line.solidFill = "FF0000"
s2.graphicalProperties.dashStyle = "dash"
s2.graphicalProperties.line.width = 5000  #控制线条的粗细
ws.add_chart(chart, "A10")
wb.save("scatter1.xlsx")
2021-06-10 10:37
frefly0203
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2021-1-9
得分:0 
谢谢版主!!!!!
2021-06-10 14:13



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-505988-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018719 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved