无法使用 CATALINA 找到 qt 或 x11 终端 gnuplot
Can't find qt or x11 terminal gnuplot with CATALINA
我在装有 Catalina 10.15.13 的 Macbook 上安装了 gnuplot。当我在 Xcode 中使用它时,它没有显示任何内容,它提供了
WARNING: Plotting with an 'unknown' terminal.
No output will be generated. Please select a terminal with 'set terminal'.
话虽如此,我看到要绘制我需要的终端 qt 或 x11 的数据,但我没有。问题有两个:
如何安装它们?自制软件不允许我使用 brew "install gnuplot --with-x11"
为了看数据,需要这两个终端吗?我不能用另一个吗?
我被要求做的是在我的程序中调用 gnuplot,而不是从终端控制它。它有效,但它不会在图表打开时保持 window。 utils.h里面有一些函数和结构体实例,但并不是和gnuplot无关。
我的代码是:
#include "utils.h"
#include <stdio.h>
char* commandsForGnuplot[] = {
"set style increment default",
"set title 'Simple Plots'",
"set title font ',20' norotate",
"set xrange[*:*] noreverse writeback",
"set x2range[*:*] noreverse writeback",
"set yrange[*:*] noreverse writeback",
"set y2range[*:*] noreverse writeback",
"set zrange[*:*] noreverse writeback",
"set cbrange[*:*] noreverse writeback",
"set rrange[*:*] noreverse writeback",
"plot[-pi / 2:pi] cos(x), -(sin(x) > sin(x + 1) ? sin(x) : sin(x + 1))"
};
int main(int argc, const char * argv[]) {
int n_commands = 11;
if ( argc < 2 ) { printf("Usage: %s -help for help\n", argv[0]); exit(1); }
if ( VERBOSE >= 2 ) { for (int a = 0; a < argc; a++) printf("%s ", argv[a]); printf("\n"); }
instance inst;
//////////////////////////////////////////////////////////
// Parse the command line
//////////////////////////////////////////////////////////
parse_command_line(argc,argv, &inst);
//printf(" file %s has %d non-empty lines\n", inst.input_file, number_of_nonempty_lines(inst.input_file)); exit(1);
//////////////////////////////////////////////////////////
// Parse the input file
//////////////////////////////////////////////////////////
read_input(&inst);
// if ( VRPopt(&inst) ) print_error(" error within VRPopt()");
// debug print
instance_tostring(&inst);
FILE* gnuplotPipe = popen("/usr/local/bin/gnuplot", "w");
if (!gnuplotPipe) { perror("popen gnuplot"); exit(EXIT_FAILURE); };
for (int i = 0; i < n_commands; i++)
{
fprintf(gnuplotPipe, "%s \n", commandsForGnuplot[i]);
printf("%s \n", commandsForGnuplot[i]);
}
pclose(gnuplotPipe);
return 0;
}
我在 macOS Catalina 上尝试了以下操作,它工作正常:
# Remove existing stuff to be sure my technique really works!
brew rm qt gnuplot
# Install qt and gnuplot afresh
brew install qt gnuplot
然后,在终端中,或者最好在您的登录脚本中,以便在您每次登录时设置:
export GNUTERM=qt
现在您可以使用gnuplot
gnuplot
G N U P L O T
Version 5.2 patchlevel 8 last modified 2019-12-01
Copyright (C) 1986-1993, 1998, 2004, 2007-2019
Thomas Williams, Colin Kelley and many others
gnuplot home: http://www.gnuplot.info
faq, bugs, etc: type "help FAQ"
immediate help: type "help" (plot window: hit 'h')
Terminal type is now 'qt'
Options are '0 font "Sans,9"'
gnuplot> plot sin(x)
我不明白你是怎么使用的gnuplot
。据我所知,您可以执行以下任一操作:
方法一
只需在终端中输入 gnuplot
,您就会得到如上所示的消息和提示符 gnuplot>
。然后键入绘图命令并在完成后键入 quit
。
方法二
直接在 gnuplot
命令后键入绘图命令,如下所示:
gnuplot -p -e "plot sin(x)"
方法三
将您的绘图命令放入名为 plot.cmds
的脚本中,如下所示:
plot sin(x)
然后告诉gnuplot
到运行那个脚本:
gnuplot -p -c plot.cmds
关键字:macOS、Catalina、gnuplot、Qt、GNUTERM
我在装有 Catalina 10.15.13 的 Macbook 上安装了 gnuplot。当我在 Xcode 中使用它时,它没有显示任何内容,它提供了
WARNING: Plotting with an 'unknown' terminal.
No output will be generated. Please select a terminal with 'set terminal'.
话虽如此,我看到要绘制我需要的终端 qt 或 x11 的数据,但我没有。问题有两个:
如何安装它们?自制软件不允许我使用 brew "install gnuplot --with-x11"
为了看数据,需要这两个终端吗?我不能用另一个吗?
我被要求做的是在我的程序中调用 gnuplot,而不是从终端控制它。它有效,但它不会在图表打开时保持 window。 utils.h里面有一些函数和结构体实例,但并不是和gnuplot无关。 我的代码是:
#include "utils.h"
#include <stdio.h>
char* commandsForGnuplot[] = {
"set style increment default",
"set title 'Simple Plots'",
"set title font ',20' norotate",
"set xrange[*:*] noreverse writeback",
"set x2range[*:*] noreverse writeback",
"set yrange[*:*] noreverse writeback",
"set y2range[*:*] noreverse writeback",
"set zrange[*:*] noreverse writeback",
"set cbrange[*:*] noreverse writeback",
"set rrange[*:*] noreverse writeback",
"plot[-pi / 2:pi] cos(x), -(sin(x) > sin(x + 1) ? sin(x) : sin(x + 1))"
};
int main(int argc, const char * argv[]) {
int n_commands = 11;
if ( argc < 2 ) { printf("Usage: %s -help for help\n", argv[0]); exit(1); }
if ( VERBOSE >= 2 ) { for (int a = 0; a < argc; a++) printf("%s ", argv[a]); printf("\n"); }
instance inst;
//////////////////////////////////////////////////////////
// Parse the command line
//////////////////////////////////////////////////////////
parse_command_line(argc,argv, &inst);
//printf(" file %s has %d non-empty lines\n", inst.input_file, number_of_nonempty_lines(inst.input_file)); exit(1);
//////////////////////////////////////////////////////////
// Parse the input file
//////////////////////////////////////////////////////////
read_input(&inst);
// if ( VRPopt(&inst) ) print_error(" error within VRPopt()");
// debug print
instance_tostring(&inst);
FILE* gnuplotPipe = popen("/usr/local/bin/gnuplot", "w");
if (!gnuplotPipe) { perror("popen gnuplot"); exit(EXIT_FAILURE); };
for (int i = 0; i < n_commands; i++)
{
fprintf(gnuplotPipe, "%s \n", commandsForGnuplot[i]);
printf("%s \n", commandsForGnuplot[i]);
}
pclose(gnuplotPipe);
return 0;
}
我在 macOS Catalina 上尝试了以下操作,它工作正常:
# Remove existing stuff to be sure my technique really works!
brew rm qt gnuplot
# Install qt and gnuplot afresh
brew install qt gnuplot
然后,在终端中,或者最好在您的登录脚本中,以便在您每次登录时设置:
export GNUTERM=qt
现在您可以使用gnuplot
gnuplot
G N U P L O T
Version 5.2 patchlevel 8 last modified 2019-12-01
Copyright (C) 1986-1993, 1998, 2004, 2007-2019
Thomas Williams, Colin Kelley and many others
gnuplot home: http://www.gnuplot.info
faq, bugs, etc: type "help FAQ"
immediate help: type "help" (plot window: hit 'h')
Terminal type is now 'qt'
Options are '0 font "Sans,9"'
gnuplot> plot sin(x)
我不明白你是怎么使用的gnuplot
。据我所知,您可以执行以下任一操作:
方法一
只需在终端中输入 gnuplot
,您就会得到如上所示的消息和提示符 gnuplot>
。然后键入绘图命令并在完成后键入 quit
。
方法二
直接在 gnuplot
命令后键入绘图命令,如下所示:
gnuplot -p -e "plot sin(x)"
方法三
将您的绘图命令放入名为 plot.cmds
的脚本中,如下所示:
plot sin(x)
然后告诉gnuplot
到运行那个脚本:
gnuplot -p -c plot.cmds
关键字:macOS、Catalina、gnuplot、Qt、GNUTERM