kookma / ogpf Goto Github PK
View Code? Open in Web Editor NEWogpf is Object based interface to GnuPlot from Fortran 2003, 2008 and later
License: Other
ogpf is Object based interface to GnuPlot from Fortran 2003, 2008 and later
License: Other
Very cool functionality.
I have tried FPM. It works.
But usually I use Visual Studio for easy debugging. Is that possible to be integrated with VS and how?
Thanks,
All the plots that have multiple plots on them, e.g., example 9:
call gp%plot(x(1:i),y(1:i), 'w lines lc "red" lw 2', &
x(i:i), y(i:i),'w points ps 3 pt 7 lc "red"', &
x(1:i),z(1:i), 'w lines lc "blue" lw 2', &
x(i:i), z(i:i), 'w points ps 3 pt 7 lc "blue"' )
fail with the following error:
27 | call gp%plot(x(1:i),y(1:i), 'w lines lc "red" lw 2', &
| 1
Error: Found no matching specific binding for the call to the GENERIC ‘plot’ at (1)
Compilation failed for object " app_plot_ogpf.f90.o "
I am using fpm
with gfortran 11.2.
How do I plot errorbars with ogpf? In gnuplot, this is possible via e.g. "plot 'a.file' u 1:2:3 with errorbars", "plot 'a.file' u 1:2:3 with xerrorbars", "plot 'a.file' u 1:2:3 with yerrorbars" or "plot 'a.file' u 1:2:3:4 with xyerrorbars".
I'm unable to see the plots with wxt term in macOS because Gnuplot exist and the window close very fast.
Using persistent:
gnuplot -p ogpf_temp_script.gp
does not work.
I managed to see the plot by adding pause mouse close or pause -1 to the end of the script.
I wonder if it is possible to set this option from the Fortran program.
Thanks in advance
Best
Manuel
Hi, Is it possible to plot point data with color scale (based on the value in the 3rd column) similar to https://codeyarns.com/tech/2015-06-19-how-to-plot-points-in-color-in-gnuplot.html
If not, is there a way to add another data column to the output .gp file generated by ogpf?
Thanks in advance!
The function interface doesn't allow to set one specific range like yrange
or zrange
without having to set the xrange
I suggest using optional arguments to set each individual argument and/or maybe writing 3 new methods to each one.
EDIT: However would be nice to keep the old interface, so maybe this would be a extension
type, public :: gpf
private
(...)
contains
(...)
procedure, pass, public :: axis => set_axis_matlab, set_axis_individuals
end type
(...)
subroutine set_axis_matlab(this, range_array)
(...) original implementation
end subroutine
(...)
subroutine set_axis_individuals(this, xrange, yrange, zrange)
class(gpf):: this
real(wp), optional, intent(in) :: xrange(2)
real(wp), optional, intent(in) :: yrange(2)
real(wp), optioanl, intent(in) :: zrange(2)
if (present(xrange)) then
this%hasxrange=.true.
this%xrange=xrange
end if
if (present(yrange)) then
this%hasyrange=.true.
this%yrange=yrange
end if
if (present(zrange)) then
this%haszrange=.true.
this%zrange=zrange
end if
end subroutine
PS "forking" the issue from #5 to a specific one
Hi there! I am wondering is it possible to use custom palette if I store the .pal file from the gnuplot-palettes in some path?
Thank you for this wonderful project!
Hi,
Would it be possible to incorporate the splot functionality into ogpf? I would like to plot slices of 3D arrays (similar to the imshow functionality of matplotlib)
Thanks
In the subroutine below it is better to write
x=real([-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8], kind=wp)
instead of
x=dble([-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8])
for flexibility.
subroutine exmp01
type(gpf):: gp
integer, parameter:: n=17
real(wp):: x(n)
real(wp):: y(n)
! Input data
! x=dble([-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8])
x=dble([-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8])
x= abs(x) + 5
y=dble([66,51,38,27,18,11,6,3,2,3,6,11,18,27,38,51,66])
! Annotation: set title, xlabel, ylabel
call gp%title('Example 1. A simple xy plot','#990011')
call gp%xlabel('my x axis ...','#99aa33',font_name="Tahoma")
! call gp%ylabel('my y axis ...')
call gp%options('set border lc "#99aa33"; set ylabel "my label..." tc "#99aa33"')
call gp%options('set logscale y2')
call gp%plot(x, y)
end subroutine exmp01
The program does not compile if wp = sp
in ogpf.f90.
https://kookma.github.com/ogpf is broken. Has the site moved to another address?
I want to know how to set the label of each line when plotting a matrix in exmp08, thanks!
I faced the following issue and was able to find the fix. I hope sharing it will save some time for people facing the same problem.
I tried compiling demo.f90 with the 2 modules provided at http://mfort.codeplex.com/, when I tried to execute the program it did create the temp file "ogpf_temp_script_file.plt" but it was completely empty. Instead the gnuplot commands were written in a fortran error file "fort.2". The name of this error file varies every time I execute the program. I am setting terminal to "x11".
Additional info:
I made the following change to all the OPEN statements and it fixed the probem:
Original: OPEN ( Newunit = file_unit, FILE = this%txtfileName, STATUS = 'replace',IOSTAT = this%Status )
Modified: OPEN ( unit = file_unit, FILE = this%txtfileName, IOSTAT = this%Status )
Do I understand correctly that the terminal option cannot be set from the Fortran client? Shouldn't ogpf
allow the user to do that with the options
command?
My understanding is that currently you need to directly modify the source at line:
Lines 163 to 165 in 7b414be
This, in my opinion, makes unfeasible any usage through fpm
. If your OS does not allow the hard-coded wxt
parameter you have the only option to fork the source file and manually include it in your project, which totally defeats the purpose of a fpm.toml
file.
I'm very happy to find the tool which enable me to use gnuplot from fortran. Thank you for your great job.
I sometimes use the compiler other than gfortran. When I tried to compile this project with that compiler, I encounter some problems like below.
"kind parameter is not defined" : default kind specification system is different between compilers, if kind specification is given by number directly, compilation failed without "non-default" settings.
"segmentation fault occured": When not allocated character object is used in the "len_trim" function, sometimes segmentation fault occures.
"error from gnuplot in example 108": Demo program (Example 108) cause error from gnuplot because line color is blank.
May I send pull request?
Hello,
Isn't it better to have the "pause_seconds" as real rather than integer? so we can use for example pause 0.5 etc...
Hello,
Do you think it is possible to extend ogpf so that it can multiplot animation? Or is it limited by gnuplot or fortran arrays itself?
Is there a way to plot continuously in the same figure?
First of all, good job.
I noticed some issues with the function set_axis
:
[-2.0943951023931956E-002, 0.13463968515384828 , -5.0000000000000000, 200.00000000000000]
And this is the output:
set xrange [-0.:0.]
set yrange [-5., 200.]
which gives me a error
"ogpf_temp_script.gp" line 6953: Can't plot with an empty x range!
subroutine set_axis(this, xrange, yrange, zrange)
class(gpf):: this
real(wp), optional, intent(in) :: xrange(2)
real(wp), optional, intent(in) :: yrange(2)
real(wp), optioanl, intent(in) :: zrange(2)
if (present(xrange)) then
this%hasxrange=.true.
this%xrange=xrange
end if
if (present(yrange)) then
this%hasyrange=.true.
this%yrange=yrange
end if
if (present(zrange)) then
this%haszrange=.true.
this%zrange=zrange
end if
end subroutine
Since version 5 (released almost 7 years ago) gnuplot offers data blocks, a more flexible way to in-line data for repeated plotting. It might be worth using this new functionality.
From what I could understand from the code and README.md, the only way to plot sets of x,y,z points in a 2d raster would be with a contour plot. However, I am not that experience with the software, so I'd like to know if there is a way to do that.
Hi @kookma !
This is awesome package, love it!
Just a small suggestion, not an issue.
Do you think perhaps you could at some place let the user choose to plot without wait? I mean so that it can plot several plots simultaneously without wait for the previous one to complete.
E.g, at wait = .false. in call execute_command_line,
call execute_command_line ('wgnuplot -persist ' // this%txtfilename, wait = .false. )
Thanks!
Best regards,
Rong
$ 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
Code::Blocks IDE for Fortran has a demonstration Compilation of existing Fortran code with Code::Blocks IDE using the older version of ogpf, which is now replaced by the project in this repository.
However, in this project, the original code layout seems to be out of use. So, would you please give me some hints on debugging ogpf and its demo hosted in the repository within cbfortran?
Regards,
HZ
in ogpf.f90
character(len=*), parameter :: md_name = 'ogpf libray'
should be 'ogpf library'
Thanks for the project.
>gfortran -c -Wextra -Wall ogpf.f90
ogpf.f90:1348:20:
1348 | integer:: j
| 1
Warning: Unused variable 'j' declared at (1) [-Wunused-variable]
ogpf.f90:1345:22:
1345 | integer:: ncx
| 1
Warning: Unused variable 'ncx' declared at (1) [-Wunused-variable]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.