用户工具

站点工具


atk:plt脚本与应用实践

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
后一修订版
前一修订版
atk:plt脚本与应用实践 [2018/04/11 19:46] – [数据线] fermiatk:plt脚本与应用实践 [2018/04/14 10:09] (当前版本) – [数据线] fermi
行 1: 行 1:
-====== plt脚本与应用实践 ======+====== plt 作图脚本与应用实践 ======
  
-QuantumATK 使用 matplotlib 作图,绝大多数候,作图可以在Virtual NanoLab上通过鼠标操作作图定制。从2017版开始,用户可以将二维数据作图保存成plt脚本(实际为python语言脚本),这样做有很多好处:+**关键词:atkpython,能带,DOS,matplotlib** 
 + 
 +使用 QuantumATK 作图时可以在Virtual NanoLab上通过鼠标操作作图进行定制并导出需要的图片格式。从2017版开始,用户可以将二维数据作图保存成plt脚本(实际为python语言脚本),这样做有很多好处:
   * 可以保存用户自己设置的自定义图像,下次直接打开,不用再重新设置;也便于与同事共享相关的数据;   * 可以保存用户自己设置的自定义图像,下次直接打开,不用再重新设置;也便于与同事共享相关的数据;
   * 可以对数据进行导出、修改等操作;   * 可以对数据进行导出、修改等操作;
行 150: 行 152:
 ===== 使用plt脚本定制图像 ===== ===== 使用plt脚本定制图像 =====
  
-==== 定制字体 ====+==== 定义颜色 ==== 
 + 
 +常见的颜色定义方法有: 
 + 
 +  *  以下单个字母:'b'(<color blue>blue</color>), 'g'(<color green>green</color>), 'r'(<color red>red</color>), 'c'(<color cyan>cyan</color>), 'm'(<color magenta>magenta</color>), 'y'(<color yellow>yellow</color>), 'k'(<color black>black</color>), 'w'(white); 
 +  *  X11/CSS4 颜色英文名,参见:[[https://en.wikipedia.org/wiki/X11_color_names]]; 
 +  *  xkcd 颜色英文名, (例如, 'xkcd:sky blue'),参见:[[https://xkcd.com/color/rgb/]]; 
 +  *  16进制 RGB 或 RGBA 字符串 (e.g., '#0F0F0F' or '#0F0F0F0F'); 
 +  *  RGB 或 RGBA 的数值 [0, 1] (例如, (0.1, 0.2, 0.5) or (0.1, 0.2, 0.5, 0.3)); 
 + 
 + 
 +==== 定义字体 ====
  
 matplotlib使用dictionary定义字体,例如可以将下面定义添加于脚本开头的部分的imports之后,setup plot之前,以供后面使用。 matplotlib使用dictionary定义字体,例如可以将下面定义添加于脚本开头的部分的imports之后,setup plot之前,以供后面使用。
行 158: 行 171:
         'color'  : 'red',         'color'  : 'red',
         'weight' : 'normal',         'weight' : 'normal',
 +        'variant': 'normal',
         'size'   : 20,         'size'   : 20,
         }         }
 </code> </code>
 +
 +可选项:
 +
 +  * family: 可使用的名称有 ‘serif’, ‘sans-serif’, ‘cursive’, ‘fantasy’, or ‘monospace’ (这些字体的实际效果依赖于系统环境);还可以直接使用操作系统的字体名称,例如:‘Arial’,‘Courier New’,‘Times New Roman’等等。
 +  * style: 可选 ‘normal’, ‘italic’ or ‘oblique’;
 +  * variant: 可选 ‘normal’ or ‘small-caps’;
 +  * stretch: 可选 0-1000 数值或以下字符串 ‘ultra-condensed’, ‘extra-condensed’, ‘condensed’, ‘semi-condensed’, ‘normal’, ‘semi-expanded’, ‘expanded’, ‘extra-expanded’ or ‘ultra-expanded’;
 +  * weight: 可选 0-1000 的数值或者以下字符串 ‘ultralight’, ‘light’, ‘normal’, ‘regular’, ‘book’, ‘medium’, ‘roman’, ‘semibold’, ‘demibold’, ‘demi’, ‘bold’, ‘heavy’, ‘extra bold’, ‘black’;
 +  * size: 可选绝对字体大小(例如 20)或以下字符串 ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’。
  
  
行 175: 行 198:
 <code python> <code python>
 axes_0.set_title(u'Bandstructure of Silicon', fontdict=fontdd, loc='right') axes_0.set_title(u'Bandstructure of Silicon', fontdict=fontdd, loc='right')
 +</code>
 +
 +==== 绘图尺寸、精度 ====
 +
 +找到开头的pyplot一句,可控制绘图尺寸、精度和颜色。这个选项仅影响图形显示,最后导出时,依赖于实际的缩放。
 +
 +<code>
 +figure = pyplot.figure(figsize=(4,3), dpi=150, facecolor="yellow")
 </code> </code>
  
行 208: 行 239:
 </code> </code>
  
-线型+=== 线型(line style)定义 === 
 |  '-' or 'solid'  |  solid line  | |  '-' or 'solid'  |  solid line  |
-|  '--' or 'dashed'  |  dashed line  |+|  '--'(双短线) or 'dashed'  |  dashed line  |
 |  '-.' or 'dashdot'  |  dash-dotted line  | |  '-.' or 'dashdot'  |  dash-dotted line  |
 |  ':' or 'dotted'  |  dotted line  | |  ':' or 'dotted'  |  dotted line  |
行 217: 行 249:
 |  ''    draw nothing   | |  ''    draw nothing   |
  
-定义marker形状请参考:https://matplotlib.org/api/markers_api.html+=== marker形状定义 === 
 + 
 +marker description 
 +|  "."  |  point    |   
 +|  ","  |     pixel     
 +|  "o"  |     circle     
 +|  "v"  |     triangle_down     
 +|  "$^$"  |     triangle_up     
 +|  "<"  |     triangle_left     
 +|  ">"  |     triangle_right     
 +|  "1"  |     tri_down     
 +|  "2"  |     tri_up     
 +|  "3"  |     tri_left     
 +|  "4"  |     tri_right     
 +|  "8"  |     octagon     
 +|  "s"  |     square     
 +|  "p"  |     pentagon     
 +|  "P"  |     plus (filled)     
 +|  "*"  |     star     
 +|  "h"  |     hexagon1     
 +|  "H"  |     hexagon2     
 +|  "+"  |     plus     
 +|  "x"  |         
 +|  "X"  |     x (filled)    |   
 +|  "D"  |     diamond     
 +|  "d"  |     thin_diamond     
 +|  "$|$"  |   vline  |  
 +|  "_"  |     hline     
 +|  TICKLEFT      tickleft     
 +|  TICKRIGHT  |    tickright     
 +|  TICKUP           tickup     
 +|  TICKDOWN      tickdown     
 +|  CARETLEFT  |     caretleft (centered at tip)     
 +|  CARETRIGHT  |      caretright (centered at tip)     
 +|  CARETUP      caretup (centered at tip)     
 +|  CARETDOWN  |     caretdown (centered at tip)     
 +|  CARETLEFTBASE  |     caretleft (centered at base)     
 +|  CARETRIGHTBASE  |     caretright (centered at base)     
 +|  CARETUPBASE  |     caretup (centered at base)     
 +|  "None", " " or ""  |     nothing     
 + 
 +更多定义请参考:[[https://matplotlib.org/api/markers_api.html]]
  
  
行 236: 行 309:
 </code> </code>
  
-经过如上设置,能带作图示例如下:+==== 进一步加工和导出 ====
  
 +经过如上设置,plt脚本可能无法在VNL的2D plot editor里作图,但仍然可以用上述第二种方法在cmd命令行作图。示例如下:
 +
 +{{ :atk:plt-final-result.png?500 |}}
 +
 +此时,仍然可以进一步使用作图工具调整一些性质(点击绿色“对号”),以便导出。
 +
 +点击“磁盘”图标,导出png(像素受限)或pdf(任意缩放)。
 {{ :atk:plt_band_modified.png?400 |}} {{ :atk:plt_band_modified.png?400 |}}
 +
  
atk/plt脚本与应用实践.1523447169.txt.gz · 最后更改: 2018/04/11 19:46 由 fermi

© 2014-2022 费米科技(京ICP备14023855号