matlab半小提琴图,matplotlib – 分开的小提琴图的一半,以比较尾部数据

本文探讨了如何改进小提琴图的数据展示方法,特别是针对难以处理的‘瘦尾’部分。作者通过调整数据分布来改善数据吸收精度,并提供了具体的Python代码实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

有没有办法将“分裂”的小提琴小提琴(或其他类型的小提琴情节)的两半分开?我正在尝试比较两种不同的治疗方法,但是有一条瘦小的尾巴,很难(不可能)判断分开的小提琴的一半或两半是否一直上升到尾尖.

VPGOH.png

我有一个想法是,如果两半略微分开而不是彼此相邻,那么就很容易准确地吸收数据.

这是我的代码:

import pandas as pd

import numpy as np

import matplotlib.pyplot as plt

from matplotlib import style

import seaborn as sns

# load data into a dataframe

df1 = pd.read_excel('Modeling analysis charts.xlsx',

sheetname='lmps',

parse_cols=[0,5],

skiprows=0,

header=1)

# identify which dispatch run this data is from

df1['Run']='Scheduling'

# load data into a dataframe

df2 = pd.read_excel('Modeling analysis charts.xlsx',

sheetname='lmps',

parse_cols=[7,12],

skiprows=0,

header=1)

# identify which dispatch run this data is from

df2['Run']='Pricing'

# drop rows with missing data

df1 = df1.dropna(how='any')

df2 = df2.dropna(how='any')

# merge data from different runs

df = pd.concat([df1,df2])

# LMPs are all opposite of actual values, so correct that

df['LMP'] = -df['LMP']

fontsize = 10

style.use('fivethirtyeight')

fig, axes = plt.subplots()

sns.violinplot(x='Scenario', y='LMP', hue='Run', split=True, data=df, inner=None, scale='area', bw=0.2, cut=0, linewidth=0.5, ax = axes)

axes.set_title('Day Ahead Market')

#axes.set_ylim([-15,90])

axes.yaxis.grid(True)

axes.set_xlabel('Scenario')

axes.set_ylabel('LMP ($/MWh)')

#plt.savefig('DAMarket.pdf', bbox_inches='tight')

plt.show()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值