当我在散景图上绘制 10+ 曲线时出现问题

problem when i plot 10+ curve on bokeh plotting

提问人:Antoine Bois 提问时间:11/16/2023 最后编辑:Antoine Bois 更新时间:11/17/2023 访问量:58

问:

我在散景图上绘制温度曲线,当曲线数量为 9 或更少时,它有效。 当我尝试绘制 10 条或更多时,散景图上只有 1 条曲线,并且比例与以前不同。 似乎正在绘制的曲线只是整个曲线的一小部分。我检查了数据的长度,9 条和 10 条曲线之间没有区别,所以我不明白问题出在哪里

enter image description here enter image descrenter image description hereiption here

这是我的代码:

def afficher_graphique(源代码,moyenne_values):

output_file("graphique.html")

p = figure(title="Température Rack", x_axis_label='Date', y_axis_label='T°C_rack', plot_width=1500, plot_height=300)
clim_names = source.data.get('clim_name', [])
renderers = []

color = ['red','blue','black','navy','deepskyblue','green','red','grey','orange','cyan','magenta','red','teal'
          ,'black','purple']

for i, clim_name in enumerate(clim_names):
    column_name = f'Tr_{i + 1}'  # Assurez-vous que le nom de la colonne est correct
    if column_name in source.data:
        line_color = color[i]
        line = p.line('date', column_name, source=source, line_color=line_color)
        renderers.append(line)

p.xaxis.formatter = DatetimeTickFormatter(days="%d/%m/%y")

legend_items = [(clim_name, [line]) for clim_name, line in zip(clim_names, renderers)]

# Ajoutez les valeurs moyennes à la légende
legend_items_with_values = [(f"{clim_name} ({moyenne_value}°C)", line)
    for (clim_name, line), moyenne_value in zip(legend_items, moyenne_values)]

legend = Legend(items=legend_items_with_values, location="center")
p.add_layout(legend, 'right')

hover = HoverTool(tooltips=[('Value', '$y')])  # Outil permettant d'afficher les infos du graph lorsqu'on le survole
tool_list = [hover]
p.add_tools(*tool_list)

show(p, notebook_handle=True)

##################################################################

def run_simulation(pays, batterie, container, chemin_accès_soll, chemin_accès_temp):

# Constantes pour les noms de clés
DATE_KEY = "dates"
TEMP_KEY = "temperatures"
CLIM_NAME_KEY = "clim_names"
MOYENNE_KEY = "moyenne_Tr"
MIN_KEY = "minimum_Tr"
MAX_KEY = "maximum_Tr"

dico_general = localisation(pays)

results = {DATE_KEY: [], TEMP_KEY: [], CLIM_NAME_KEY: [], MOYENNE_KEY: [], MIN_KEY: [], MAX_KEY: []}  

for clim in dico_general:
    
    result_clim = main_simu_thermique(.................

........................................................... ........................................................... ..........这是我main_simu_thermique参数...... ..........................................................)

    print (len(f"Températures : {result_clim['Tr']}"))
    
    results[DATE_KEY].append(result_clim["date"])
    results[TEMP_KEY].append(result_clim["Tr"])
    results[CLIM_NAME_KEY].append(clim)
    
    moyenne_value = result_clim["Moy_Tr"]
    moyenne_1_decimale = round_values(moyenne_value)
    results[MOYENNE_KEY].append(moyenne_1_decimale)
    print(f"Pour {clim}, la T°C moyenne est : {moyenne_1_decimale}")

    min_value = result_clim["Min_Tr"]
    min_1_decimale = round_values(min_value)
    results[MIN_KEY].append(min_1_decimale)
    print(f"Pour {clim}, la T°C min est : {min_1_decimale}")

    max_value = result_clim["Max_Tr"] 
    max_1_decimale = round_values(max_value)
    results[MAX_KEY].append(max_1_decimale)
    print(f"Pour {clim}, la T°C max est : {max_1_decimale}")
            
return results

#########################################################

DEF模拟(Pays、Batterie、Container、Fenetre、chemin_accès_soll、chemin_accès_temp):

if fenetre and isinstance(fenetre, Tk):
    fenetre.destroy()

results = run_simulation(pays, batterie, container, chemin_accès_soll, chemin_accès_temp)

source_data = {"date": results["dates"][0]}

for i, temperatures in enumerate(results["temperatures"]):
    source_data[f'Tr_{i + 1}'] = temperatures

source_data["Moy_Tr"] = results["moyenne_Tr"]
source_data["Min_Tr"] = results["minimum_Tr"]
source_data["Max_Tr"] = results["maximum_Tr"]
source_data["clim_name"] = results["clim_names"]

source = ColumnDataSource(data=source_data)
afficher_graphique(source, results["moyenne_Tr"])

check_simulation_data(results)

如果名称 == “main”: dropdown_list()

##################################################################

如何在散景上绘制 10+ cruve?

谢谢你的帮助

Python 绘制 散景 曲线

评论

0赞 toyota Supra 11/16/2023
请以文本形式发布代码,而不是屏幕截图
0赞 Sembei Norimaki 11/16/2023
please post the data and code you are executing
0赞 Antoine Bois 11/17/2023
data are very long (1440 values per column), so i can't post it
0赞 mosc9575 11/19/2023
Could you please show the head of the data, maybe 5 values per column?
0赞 Antoine Bois 11/20/2023
here is an example of timedata and temperatures associate : Date : [Timestamp('2018-07-28 00:00:00'), Timestamp('2018-07-28 00:01:00'), Timestamp('2018-07-28 00:02:00'), Timestamp('2018-07-28 00:03:00'), Timestamp('2018-07-28 00:04:00'), Timestamp('2018-07-28 00:05:00'), Timestamp('2018-07-28 00:06:00'), Timestamp('2018-07-28 00:07:00'), Timestamp('2018-07-28 00:08:00'), Timestamp('2018-07-28 00:09:00') Températures : [23.0, 23.000425944046633, 23.001219174992464, 23.00232909111743, 23.00371233781407, 23.005331757056137, 23.007155489437704, 23.00915620686359, 23.01131045685976,

答: 暂无答案