用CATALINA找不到qt或x11终端gnuplot [英] Can't find qt or x11 terminal gnuplot with CATALINA

查看:479
本文介绍了用CATALINA找不到qt或x11终端gnuplot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Macbook上使用Catalina 10.15.13安装了gnuplot.当我在Xcode中使用它时,它没有显示任何内容,它提供了

I installed gnuplot on my Macbook with Catalina 10.15.13. When I use it in Xcode it does not show me anything, it provides

警告:使用未知"终端进行绘图.

WARNING: Plotting with an 'unknown' terminal.

将不会生成任何输出.请选择带有设置终端"的终端.

No output will be generated. Please select a terminal with 'set terminal'.

话虽如此,我看到要绘制我不需要的端子qt或x11所需的数据.问题是两个:

Having said that, I saw that to plot data I would need of the terminals qt or x11 which I do not have. The questions are two:

  1. 如何安装它们?自制软件不允许我使用brew"install gnuplot --with-x11"

  1. How can I install them? homebrew does not allow me to use brew "install gnuplot --with-x11"

为了查看数据,我是否需要这两个端子?我不能再用一个吗?

In order to see the data, Do I have to need of this two terminals? Can't I use another one?

我被要求做的是在程序中调用gnuplot,而不是从终端进行控制.它可以工作,但不能在打开图表的情况下保持窗口打开.在utils.h中,有一些函数和结构实例,但与gnuplot无关. 我的代码是:

What I'm asked to do is to call gnuplot inside my program, and not controlling it from the terminal. It works, but it does not keep thw window with chart open. Inside utils.h there are some function and the structure instance, but it does not have nothing to do with gnuplot. My code is:

#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上尝试了以下操作,效果很好:

I tried the following on macOS Catalina and it works fine:

# Remove existing stuff to be sure my technique really works!
brew rm qt gnuplot

# Install qt and gnuplot afresh
brew install qt gnuplot

然后,在终端中,或者最好在您的登录脚本中,这样每次登录时都会对其进行设置:

Then, in Terminal, or preferably in your login script so it is set every time you login:

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. AFAIK,您可以执行以下任一操作:

I don't understand how you are using gnuplot. AFAIK, you can do any of the following:

方法1

只需在终端中键入gnuplot,您将得到上面显示的消息和提示符gnuplot>.然后,键入绘图命令,并在完成后键入quit.

Simply type gnuplot in Terminal, and you will get the messages shown above and the prompt gnuplot>. You then type your plotting commands and type quit when you are finished.

方法2

直接在gnuplot命令之后键入绘图命令,如下所示:

Type your plotting commands directly following the gnuplot command like this:

gnuplot -p -e "plot sin(x)"

方法3

将绘图命令放在名为plot.cmds的脚本中,如下所示:

Put your plotting commands in a script called plot.cmds like this:

plot sin(x)

然后告诉gnuplot运行该脚本:

gnuplot -p -c plot.cmds

关键字:macOS,Catalina,gnuplot,Qt,GNUTERM

Keywords: macOS, Catalina, gnuplot, Qt, GNUTERM

这篇关于用CATALINA找不到qt或x11终端gnuplot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆