Code Monkey home page Code Monkey logo

ogpf's People

Contributors

14ngiestas avatar atilasaraiva avatar ily83 avatar kookma avatar lkedward avatar sakamoti avatar tammasloughran avatar zoziha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ogpf's Issues

ENH: improve set_axis interface to allow set individual axis range

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

Issues with `set_axis`

First of all, good job.
I noticed some issues with the function set_axis:

  1. There is a problem with small numbers and the descriptor F0.0 you are using there.
    I passed this vector to the function:
[-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!
  1. The interface don'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 or maybe writing 3 new methods to each one
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

use real(x, kind=wp) instead of dble(x)

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.

add optional wait = .false. to call execute_command_line ('wgnuplot -persist ' // this%txtfilename)

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

bug fix (kind specification and so on)

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?

Failing Examples

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.

The example fails on macOS

$ 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

Question

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?

Problem with the graphics library on Linux based servers

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:

  1. OS :: Linux
  2. gnuplot :: Version 4.2 patchlevel 6
  3. gfortran :: GNU Fortran (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
  4. If I copy-paste the commands in fort.2 to a termial with gnuplot pre-loaded, it does create the required plot.

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 )

Animation Pause

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...

line label

I want to know how to set the label of each line when plotting a matrix in exmp08, thanks!

typo

in ogpf.f90

character(len=*), parameter :: md_name = 'ogpf libray'

should be 'ogpf library'

Is there a way to plot 2d heatmap?

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.

Set output terminal from the Fortran API

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:

ogpf/src/ogpf.f90

Lines 163 to 165 in 7b414be

! The terminal and font have been set for Windows operating system
! Correct to meet the requirements on other OS like Linux and Mac.
character(len=*), parameter :: gnuplot_term_type = 'wxt' ! Output terminal

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.

Question

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

Is it possible to add options after calling a plot subroutine?

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

Errorbars

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".

unused variables

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]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.