在OSX上安装gnuplot 5.0.1

37

我从源forge页面下载了gnuplot 5.0.1的源文件(gnuplot-5.0.1.tar.gz)。我还在我的OS X 10.7.5上安装了命令行工具,使得/usr/bin文件夹下有gccmake

我按照tarball中的INSTALL.gnu文件中的安装说明进行操作:运行了configure文件,然后分别输入了makemake checkmake installmake clean。这些命令将gnuplot安装在/usr/local/bin/目录下。

make check命令在测试许多gnuplot脚本之前,在shell中输出了很多行信息。我实际上可以看到绘图,并且认为“太好了,它可以用了”。因此,我打开一个新的终端shell并输入gnuplot以开始使用它(终端自动设置为qt)。但是,一个简单的plot sin(x)却失败了。Gnuplot返回如下信息:

Could not start gnuplot_qt with path "/usr/local/libexec/gnuplot/5.0/gnuplot_qt" 
Could not start gnuplot_qt with path "/usr/local/libexec/gnuplot/5.0/gnuplot_qt" 
Could not connect to gnuplot_qt "" . Starting a new one 
Could not start gnuplot_qt with path "/usr/local/libexec/gnuplot/5.0/gnuplot_qt" 

Warning: slow font initialization  .  .  .  .  .  .  .  .  .
Warning: slow font initialization  .  .  .  .  .  .  .  .  .
Warning: slow font initialization  .  .  .  .  .  .  .  .  .
Warning: slow font initialization  .  .  .  .  .  .  .  .  .

… 

如果我不关闭终端,警告消息就会无限地出现。

6个回答

72
为了减少我的工作量,我尽可能使用包管理器来安装命令行工具。
对于OS X系统,我建议使用homebrew。使用homebrew安装gnuplot非常简单,只需输入以下命令: brew install gnuplot

2
如何知道这个命令将安装哪个版本的gnuplot? - dada
1
默认情况下,brew install gnuplot将安装最新版本(目前为5.0.1)。通常,不同的主要版本会有不同的软件包(公式)。例如,如果您想安装gnuplot 4,则可以使用brew install homebrew/versions/gnuplot4。如果有疑问,始终可以访问http://braumeister.org,该网站显示有关软件包的一些详细信息。 - irundaia
1
好的,我已经使用Homebrew安装了Gnuplot 5.0.1,但是X11终端不可用。如果我需要在将图保存为PNG或其他终端之前检查它们,应该使用哪个终端? - dada
10
最终,我卸载了 gnuplot 并通过指定 x11 终端重新安装:brew uninstall gnuplot && brew install gnuplot --with-x11。这样打开 gnuplot 时会自动设置终端为 x11。 - dada
4
@dada,你的评论对于让这个工作起来非常有帮助。幸运的是我看到了它!再次感谢。 - CaladanBrood
显示剩余2条评论

11
在MacOS上使用gnuplot的最佳方法是将其设置为与aquaterm一起工作,而不是X11。以下是我在Yosemite和El Capitan MacOS上所做的:
1. 如果有任何预安装的gnuplot和aquaterm,请先删除它们:
- `Brew uninstall gnuplot` - 如果您之前通过dmg文件安装了Aquaterm,请手动删除它。 - 如果您使用brew安装了Aquaterm,则使用`brew uninstall aquaterm`。
底线:您的系统上不应该有任何gnuplot或aquaterm的安装。
  1. 使用brew命令安装aqua term:
    • brew install Caskroom/cask/aquaterm
  2. 然后使用以下命令安装gnuplot:
    • brew install gnuplot --with-aquaterm --with-qt4
  3. 最后,运行以下命令在您的路径中创建gnuplot的快捷方式
    • ln -s /usr/local/Cellar/gnuplot/5.0.4/bin/gnuplot /usr/local/bin/gnuplot

就这样,只需注意如果brew安装了不同版本的gnuplot,则gnuplot的位置可能会有所不同。

现在,如果在终端中运行gnuplot,则应该会看到类似于此的输出: gnuplot命令的输出


6
QT4不再得到支持。现在只使用QT。:brew install gnuplot --with-aquaterm --with-qt - ckg
Aquaterm对我来说无法工作。我根本看不到它的任何窗口。 - German Lashevich

5

感谢@irundaia的回答以及一些Google搜索,我终于成功地将gnuplot与我喜欢的x11终端配合使用。以下是步骤:在终端中输入:

brew uninstall gnuplot
brew install gnuplot --with-x11

第一个命令卸载之前使用homebrew安装的gnuplot。第二个命令通过指定x11终端来安装gnuplot。这样,打开gnuplot会自动将终端设置为x11,并且关于“gnuplot_qt”和“slow font initialization”的警告消息消失了

1
如果您没有安装Homebrew,可以执行以下操作:
xcode-select --install && /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" && brew install gnuplote

这个命令将安装Xcode(Homebrew所需的必要组件)、Homebrew,以及安装完后的Gnuplot。


1
我在使用Octave测试几个算法时遇到了类似的问题,因此我采取了以下措施解决了这些问题。
如果您已经安装了GNUPLOT,请尝试使用brew uninstall gnuplot卸载它。
  • Download Aquaterm from this location.
  • Once download is complete, follow the instructions for the installation
  • Open Aquaterm x.x.x.dmg
  • Double click AquatermInstaller.pkg
  • Follow the installation wizard.
  • Once Aquaterm installation is complete, install gnuplot using the below command

    brew install gnuplot –with-aquaterm —-with-qt4
    

    The above command along with gnu plot installation, also configures the terminal type to aqua, which means you don’t have to run setenv command post installation. To confirm, run the command “gnuplot” in the terminal and at the bottom of the result, you should see “Terminal type set to aqua”.

为了验证安装和配置,可以在Octave中运行以下测试:
x = 1:10
y = 1:10
plot(x,y)

这应该会启动Aquaterm和图形。


qt4已经不再是brew选项。您需要使用: brew install gnuplot --with-aquaterm --with-qt --with-x11 - GregD

-1
请正确设置以下环境参数。
GNUPLOT_DRIVER_DIR = "/usr/local/libexec/gnuplot/5.2"
GNUPLOT_PS_DIR     = "/usr/local/share/gnuplot/5.2/PostScript"
HELPFILE           = "/usr/local/share/gnuplot/5.2/gnuplot.gih"

例如:

export GNUPLOT_DRIVER_DIR="/home/boris/local/libexec/gnuplot/5.2"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接