You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Matplotlib绘图脚本中修改part.dat对应的蓝色标记颜色

Fixing the Scatter Marker Color for Your Band Plot

I see the issue here - the color parameter you're modifying only affects the band lines, not the scatter points from your part.dat data. Let's fix this step by step:

Step 1: Update the bndplot function in func.py

First, we need to add a parameter to control the scatter marker color in your bndplot function.

  1. Add a new keyword argument handler for scatter color near the top of the function:
def bndplot(datafile_full,datafile,fermi,symmetryfile,subplot,**kwargs):
    if 'shift_fermi' in kwargs:
        bool_shift_efermi = kwargs['shift_fermi']
    else:
        bool_shift_efermi = 0
    if 'color' in kwargs:
        color_bnd=kwargs['color']
    else:
        color_bnd='black'
    if 'linestyle' in kwargs:
        line_bnd=kwargs['linestyle']
    else:
        line_bnd='solid'
    # Add this new block for scatter color control
    if 'scatter_color' in kwargs:
        scatter_color = kwargs['scatter_color']
    else:
        scatter_color = 'blue'  # Keeps original default color if not specified
    # ... rest of your function code ...
  1. Modify the final plt.scatter line to use this new color parameter:
# Replace the existing scatter line with this
plt.scatter(a,b-fermi_shift,s=70*np.array(w), c=scatter_color)

Step 2: Pass the scatter color in plot.py

Now you can specify the marker color directly when calling bndplot. Just add the scatter_color parameter with your desired color (you can use named colors like 'red', 'green', or hex codes like '#FF5733'):

bndplot(datafile_full,datafile,fermi,symmetryfile,ax,shift_fermi=1,color='black',linestyle='solid',name_k_points=['K','G','M','K','H','A','L','H'], legend=El+', '+orb+'-orbital', scatter_color='red')

How This Works

The original plt.scatter call didn't specify a color, so Matplotlib used its default blue. By adding the scatter_color keyword argument, we give you explicit control over this color while maintaining backward compatibility (if you don't specify it, it will still use the original blue).

Now you can easily adjust the marker color to match your comparison needs!

内容的提问来源于stack exchange,提问作者sai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 10:57:36