Skip to content

搞英语 → 看世界

翻译英文优质信息和名人推特

Menu
  • 首页
  • 作者列表
  • 独立博客
  • 专业媒体
  • 名人推特
  • 邮件列表
  • 关于本站
Menu

iTerm2 中的内联绘图

Posted on 2023-09-15

我的大部分工作时间都花在终端上:我在那里运行文本编辑器,在那里运行程序等。我通常将 iTerm2 设置为显示许多狭窄的全高终端。然而,当我处理绘图时,我通常会这样做:

  
$ ./some-cmd.pyplot.png && 打开plot.png  

这会弹出一个带有我的绘图的预览窗口,然后我将其关闭并返回到我的编码。不过,我真正想要的是直接在我的终端中。这是可能的!

iTerm2 终端支持内联图像协议, itermplot提供了使用该协议的 matplotlib 后端。这意味着更新我的.bashrc后:

  
导出 MPLBACKEND="模块://itermplot"  
导出 ITERMPLOT="rv"  

我可以写:

  
./内联图.py:  
  #!/usr/bin/env python3  
  将 matplotlib.pyplot 导入为 plt  
  Fig, ax = plt.subplots()  
  ax.plot([0,1], [1,0])  
  plt.title("一张图")  
  plt.xlabel("x 轴")  
  plt.ylabel("y 轴")  
  plt.show()  

当我将其作为./inline-plot.py运行时,我看到:

内联图示例.png

当然,我通常会将它与许多其他具有相关工作的终端一起使用:

inline-plot-multiple-terminals.png

当显示复杂的图表时,我确实注意到它会稍微减慢该终端的速度,但它不会影响其他终端,并且当我清除它时它会恢复全速。

我才刚刚开始使用它,但我对此感到非常兴奋!它非常适合我的工作流程。

评论通过: facebook , mastodon

原文: https://www.jefftk.com/p/inline-plotting-in-iterm2

本站文章系自动翻译,站长会周期检查,如果有不当内容,请点此留言,非常感谢。
  • Abhinav
  • Abigail Pain
  • Adam Fortuna
  • Alberto Gallego
  • Alex Wlchan
  • Answer.AI
  • Arne Bahlo
  • Ben Carlson
  • Ben Kuhn
  • Bert Hubert
  • Bits about Money
  • Brian Krebs
  • ByteByteGo
  • Chip Huyen
  • Chips and Cheese
  • Christopher Butler
  • Colin Percival
  • Cool Infographics
  • Dan Sinker
  • David Walsh
  • Dmitry Dolzhenko
  • Dustin Curtis
  • Elad Gil
  • Ellie Huxtable
  • Ethan Marcotte
  • Exponential View
  • FAIL Blog
  • Founder Weekly
  • Geoffrey Huntley
  • Geoffrey Litt
  • Greg Mankiw
  • Henrique Dias
  • Hypercritical
  • IEEE Spectrum
  • Investment Talk
  • Jaz
  • Jeff Geerling
  • Jonas Hietala
  • Josh Comeau
  • Lenny Rachitsky
  • Liz Danzico
  • Lou Plummer
  • Luke Wroblewski
  • Matt Baer
  • Matt Stoller
  • Matthias Endler
  • Mert Bulan
  • Mostly metrics
  • News Letter
  • NextDraft
  • Non_Interactive
  • Not Boring
  • One Useful Thing
  • Phil Eaton
  • Product Market Fit
  • Readwise
  • ReedyBear
  • Robert Heaton
  • Ruben Schade
  • Sage Economics
  • Sam Altman
  • Sam Rose
  • selfh.st
  • Shtetl-Optimized
  • Simon schreibt
  • Slashdot
  • Small Good Things
  • Taylor Troesh
  • Telegram Blog
  • The Macro Compass
  • The Pomp Letter
  • thesephist
  • Thinking Deep & Wide
  • Tim Kellogg
  • Understanding AI
  • 英文媒体
  • 英文推特
  • 英文独立博客
©2025 搞英语 → 看世界 | Design: Newspaperly WordPress Theme