kookma / ogpf

ogpf is Object based interface to GnuPlot from Fortran 2003, 2008 and later
Other
166 stars 46 forks source link

The example fails on macOS #14

Closed certik closed 3 years ago

certik commented 3 years ago
$ fpm run --example

 gpf: gnuplot from Fortran Demonstration
 Example 1: Demo for xy plot
 Example 2: Line specification
 Example 3: Plot several data series at the same time
 Example 4: Plot four data series at the same time
 Example 5: Use line style, line colors and more...
 Example 6: An interesting plot, sin(x) and its zero on the same plot
 Example 7: Plot a matrix against a vector
 Example 8: Plot a matrix against a vector and set the linespec and legend
 Example 9: Use gnuplot for animation
 Example 10: Use ogpf options
 Example 11: simple polar plot
 Example 12: A plot with logarithmic x axis
 Example 13: A matrix plot with logarithmic y axis
 Example 14: A loglog plot
 Example 15: Plotting a function
 Example 16: Save the gnuplot script into a file for future use
 Example 17: Multi window plots, using script
 Example 18: Running an external script file
 Example 19: Multiple linestyle in matrix plot
 Example 20: Scatter plot
 Example 21: Stem plot
 Example 22: Stem plot animation
 Example 23: Another animation using matrix plot
 Example 24: Multiplot layout
 Example 25: Multiplot layout followed by simple plot
 Example 26: Plot matrix vs. matrix
 Example 27: Using secondary y axis
 Example 28: Using secondary x and y axis
 Example 29: Using color and size for title and labels
 Example 30: More on labels color and size with secondary axes

 ***   Surface and Contour Plots ***

 Example 101: Simple 3D plot using surf
 Example 102: Surface plot and color palette 
 Example 103: Surface plot with hidden details and its contour
 Example 104: Cylindrical mapping
 Example 105: More contour plot
 Example 106: Animation of 3D plots
 Example 106: Multiplot layout in 3D
 Example 107: Multiplot layout for 3D data
 Example 108: Plot a 2D grid

2D plots: select an example: 1 through 30
3D plots: select an example: 101 through 108
enter 0 for exit:  1

set term wxt size 640,480 enhanced font "verdana,10" title "ogpf libray: Rev. 0.22 of March 9th, 2018"
         ^
"ogpf_temp_script.gp" line 6: unknown or ambiguous terminal type; type just 'set terminal' for a list

 press any key to continue...

I assume the gnuplot does not work or requires set terminal on macOS. I used

conda create -n gf gfortran fpm gnuplot
conda load gf
git clone https://github.com/kookma/ogpf.git
cd ogpf
fpm run --example
kookma commented 3 years ago

Hi @certik I have not a MacOS machine to test and all my tests were on Windows and Ubuntu! but I will investigate!

@LKedward - would you have a look?

certik commented 3 years ago

I can debug this too. Thank you @kookma for the library!

kookma commented 3 years ago

Thank you @certik! So please update me here! I am not sure but I think something goes wrong with wxt terminal (on MacOS) here!

kookma commented 3 years ago

Also please test with qt terminal!

set terminal qt
set title "Some Math Functions"
set xrange [-10:10]
set yrange [-2:2]
set zeroaxis
plot (x/4)**2, sin(x), 1/x

See for example https://apple.stackexchange.com/questions/103814/cant-plot-with-gnuplot-on-my-mac

I had no issue report for wxt on MacOS and I assumed it should work as default terminal on Windows/Linux/MacOS.

Side note:

issue the below command to see what terminals are available on your system!

set terminal

LKedward commented 3 years ago

@LKedward - would you have a look?

Apologies, I don't have a Mac and so I wasn't able to test on MacOS unfortunately.

kookma commented 3 years ago

@LKedward No problem. It is not related to FPM! It seems something goes wrong with terminal!

Thank you!

certik commented 3 years ago

With qt I get:

gnuplot> set terminal qt
Terminal type is now 'qt'
gnuplot> set title "Some Math Functions"
gnuplot> set xrange [-10:10]
gnuplot> set yrange [-2:2]
gnuplot> set zeroaxis
gnuplot> plot (x/4)**2, sin(x), 1/x
Could not start gnuplot_qt with path /Users/certik/miniforge3/envs/gf/libexec/gnuplot/5.4
Did you set environmental variable GNUPLOT_DRIVER_DIR?
Could not start gnuplot_qt with path /Users/certik/miniforge3/envs/gf/libexec/gnuplot/5.4
Did you set environmental variable GNUPLOT_DRIVER_DIR?
certik commented 3 years ago

Here are the available terminals:

gnuplot> set terminal

Available terminal types:
       cairolatex  LaTeX picture environment using graphicx package and Cairo backend
           canvas  HTML Canvas object
              cgm  Computer Graphics Metafile
          context  ConTeXt with MetaFun (for PDF documents)
          domterm  DomTerm terminal emulator with embedded SVG
             dumb  ascii art for anything that prints text
              dxf  dxf-file for AutoCad (default size 120x80)
              emf  Enhanced Metafile format
         epscairo  eps terminal based on cairo
         epslatex  LaTeX picture environment using graphicx package
              fig  FIG graphics language V3.2 for XFIG graphics editor
              gif  GIF images using libgd and TrueType fonts
             hpgl  HP7475 and relatives [number of pens] [eject]
             jpeg  JPEG images using libgd and TrueType fonts
               mf  Metafont plotting standard
               mp  MetaPost plotting standard
             pcl5  PCL5e/PCL5c printers using HP-GL/2
         pdfcairo  pdf terminal based on cairo
           pict2e  LaTeX2e picture environment
              png  PNG images using libgd and TrueType fonts
         pngcairo  png terminal based on cairo
       postscript  PostScript graphics, including EPSF embedded files (*.eps)
          pslatex  LaTeX picture environment with PostScript \specials
            pstex  plain TeX with PostScript \specials
         pstricks  LaTeX picture environment with PSTricks macros
               qt  Qt cross-platform interactive terminal
          sixelgd  sixel using libgd and TrueType fonts
              svg  W3C Scalable Vector Graphics
          tek40xx  Tektronix 4010 and others; most TEK emulators
          tek410x  Tektronix 4106, 4107, 4109 and 420X terminals
          texdraw  LaTeX texdraw environment
         tkcanvas  Tk canvas widget
          unknown  Unknown terminal type - not a plotting device
            vttek  VT-like tek40xx terminal emulator
            xterm  Xterm Tektronix 4014 Mode
kookma commented 3 years ago

Here are the available terminals:

Hi @certik - the report shows you have not wxt terminal installed! but you have qt Qt cross-platform interactive terminal So technically to this point you should be able to plot using qt

kookma commented 3 years ago

Could not start gnuplot_qt with path /Users/certik/miniforge3/envs/gf/libexec/gnuplot/5.4 Did you set environmental variable GNUPLOT_DRIVER_DIR? Could not start gnuplot_qt with path /Users/certik/miniforge3/envs/gf/libexec/gnuplot/5.4 Did you set environmental variable GNUPLOT_DRIVER_DIR?

When you start a clean session of gnuplot using the below command shall display your default terminal

show terminal

By the way you have qt terminal but it can not call it correctly!

To see if you can plot, from your list of available terminal I use png terminal. Please execute the below example and let me know if you get the correct output

set terminal png size 400,300
set output 'test.png'
set title "Some Math Functions"
set xrange [-10:10]
set yrange [-2:2]
set zeroaxis
plot (x/4)**2, sin(x), 1/x

Gnuplot shall produce a test.png and you should get something like below image

certik commented 3 years ago

The png terminal works and saves the png image.

The default terminal is qt, but it does not work due to the errors:

Could not start gnuplot_qt with path /Users/certik/miniforge3/envs/gf/libexec/gnuplot/5.4
Did you set environmental variable GNUPLOT_DRIVER_DIR?
Could not start gnuplot_qt with path /Users/certik/miniforge3/envs/gf/libexec/gnuplot/5.4
Did you set environmental variable GNUPLOT_DRIVER_DIR?

The executable /Users/certik/miniforge3/envs/gf/libexec/gnuplot/5.4/gnuplot_qt is there and seems to work (it opens up an application with a menu but no windows and I assume if it was used to plot something, it would show it). So I don't know what the problem is.

kookma commented 3 years ago

Hi @certik - So gnuplot works fine! but not for qt terminal! I am sorry I cannot help more as I do not have a MacOS. But as I see the error is not related with ogpf! I have read on the net there are ways to install gnuplot+wxt on macos

https://stackoverflow.com/questions/13001847/wxt-terminal-for-gnuplot-on-mac-os-x

Please update me if you could resolve the issue!

certik commented 3 years ago

Well, I think it's always a good idea to provide instructions how to get a library (ogpf in this case) working on all platforms. Even though the problem is in gnuplot, it is related to ogpf, since ogpf depends on gnuplot to work.

kookma commented 3 years ago

Well, I think it's always a good idea to provide instructions how to get a library (ogpf in this case) working on all platforms. Even though the problem is in gnuplot, it is related to ogpf, since ogpf depends on gnuplot to work.

I will add a line and refer users to consult http://www.gnuplot.info/ and have a working gnuplot on their system, then install ogpf! If I want to add all troubleshooting related to working gnuplot on all different operating systems (e.g linus, unix, Windows, macos, ...) it wont make sense here and we repeated gnuplot.info docs here!

Thank you!

kookma commented 3 years ago

The png terminal works and saves the png image.

You can change wxt terminal in examples and use png instead. This will work for you! Also try to install wxt from https://stackoverflow.com/questions/13001847/wxt-terminal-for-gnuplot-on-mac-os-x and see how it works.

certik commented 3 years ago

Thanks @kookma for your help! I've installed gnuplot using Conda, so it would have to be fixed in Conda.