Skip to content

Commit a46a3b1

Browse files
Merge pull request #22 from jchristopherson/v1.7
V1.7
2 parents da31bad + 802d36a commit a46a3b1

435 files changed

Lines changed: 29475 additions & 27231 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.24)
33
project(
44
fplot
55
LANGUAGES Fortran
6-
VERSION 1.6.2
6+
VERSION 1.7.0
77
)
88

99
# Get helper macros and functions
@@ -26,12 +26,13 @@ add_fortran_library(
2626
${FPLOT_SOURCES}
2727
)
2828
link_library(${PROJECT_NAME} ${ferror_LIBRARY} ${ferror_INCLUDE_DIR})
29-
link_library(${PROJECT_NAME} ${iso_varying_string_LIBRARY} ${iso_varying_string_INCLUDE_DIR})
29+
link_library(${PROJECT_NAME} ${fstring_LIBRARY} ${fstring_INCLUDE_DIR})
3030
link_library(${PROJECT_NAME} ${collections_LIBRARY} ${collections_INCLUDE_DIR})
3131
link_library(${PROJECT_NAME} ${geompack_LIBRARY} ${geompack_INCLUDE_DIR})
32+
link_library(${PROJECT_NAME} ${forcolormap_LIBRARY} ${forcolormap_INCLUDE_DIR})
3233

3334
# Installation
34-
# add_subdirectory(install)
35+
add_subdirectory(install)
3536

3637
# ------------------------------------------------------------------------------
3738
# EXAMPLES

README.md

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,36 @@ A Fortran library providing a convenient interface for plotting with Gnuplot.
66
![Build Status](https://github.com/jchristopherson/fplot/actions/workflows/cmake.yml/badge.svg)
77
[![Actions Status](https://github.com/jchristopherson/fplot/workflows/fpm/badge.svg)](https://github.com/jchristopherson/fplot/actions)
88

9-
## Gnuplot
10-
This library is tailored to write script files for Gnuplot. As such, Gnuplot is required to make use of the output of this library. Gnuplot can be found [here](http://www.gnuplot.info/).
9+
## GNUPLOT
10+
This library is tailored to write script files for GNUPLOT. As such, GNUPLOT is required to make use of the output of this library. GNUPLOT can be found [here](http://www.gnuplot.info/).
1111

1212
## Documentation
1313
Documentation can be found [here](https://jchristopherson.github.io/fplot/)
1414

15+
## Building FPLOT
16+
[CMake](https://cmake.org/)This library can be built using CMake. For instructions see [Running CMake](https://cmake.org/runningcmake/).
17+
18+
[FPM](https://github.com/fortran-lang/fpm) can also be used to build this library using the provided fpm.toml.
19+
```txt
20+
fpm build
21+
```
22+
The FPLOT library can be used within your FPM project by adding the following to your fpm.toml file.
23+
```toml
24+
[dependencies]
25+
fplot = { git = "https://github.com/jchristopherson/fplot" }
26+
```
27+
28+
## External Libraries
29+
The FPLOT library depends upon the following libraries.
30+
- [FERROR](https://github.com/jchristopherson/ferror)
31+
- [COLLECTIONS](https://github.com/jchristopherson/collections)
32+
- [FSTRING](https://github.com/jchristopherson/fstring)
33+
- [GEOMPACK](https://github.com/jchristopherson/geompack)
34+
- [FORCOLORMAP](https://github.com/vmagnin/forcolormap)
35+
1536
## Example 1
1637
This example illustrates how to plot two-dimensional data.
1738
```fortran
18-
! fplot_2d_1.f90
19-
2039
program example
2140
use, intrinsic :: iso_fortran_env
2241
use fplot_core
@@ -154,54 +173,51 @@ This is the plot resulting from the above program.
154173
![](images/example_2d_plot_2.png?raw=true)
155174

156175
## Example 3
157-
The following example illustrates how to create a three-dimensional surface plot.
176+
The following example illustrates how to create a three-dimensional surface plot. The plot also leverages the [FORCOLORMAP](https://github.com/vmagnin/forcolormap) library to provide the colormap.
158177
```fortran
159-
! fplot_surf_3.f90
160-
161178
program example
162-
use, intrinsic :: iso_fortran_env
163179
use fplot_core
180+
use iso_fortran_env
181+
use forcolormap, only : colormaps_list
164182
implicit none
165183
166184
! Parameters
167185
integer(int32), parameter :: m = 50
168186
integer(int32), parameter :: n = 50
169-
real(real64), parameter :: xMax = 5.0d0
170-
real(real64), parameter :: xMin = -5.0d0
171-
real(real64), parameter :: yMax = 5.0d0
172-
real(real64), parameter :: yMin = -5.0d0
173187
174188
! Local Variables
175-
real(real64), dimension(n) :: xdata
176-
real(real64), dimension(m) :: ydata
177-
real(real64), dimension(:,:), pointer :: x, y
178189
real(real64), dimension(m, n, 2), target :: xy
190+
real(real64), pointer, dimension(:,:) :: x, y
179191
real(real64), dimension(m, n) :: z
180192
type(surface_plot) :: plt
181193
type(surface_plot_data) :: d1
182-
type(rainbow_colormap) :: map
183194
class(plot_axis), pointer :: xAxis, yAxis, zAxis
195+
type(custom_colormap) :: map
196+
type(cmap) :: colors
197+
198+
! Set up the colormap
199+
call colors%set("glasgow", -8.0d0, 8.0d0)
200+
call map%set_colormap(colors)
184201
185202
! Define the data
186-
xdata = linspace(xMin, xMax, n)
187-
ydata = linspace(yMin, yMax, m)
188-
xy = meshgrid(xdata, ydata)
203+
xy = meshgrid(linspace(-5.0d0, 5.0d0, n), linspace(-5.0d0, 5.0d0, m))
189204
x => xy(:,:,1)
190205
y => xy(:,:,2)
191206
192-
! Define the function to plot
193-
z = sin(sqrt(x**2 + y**2))
194-
195-
! Define colormap settings
196-
call map%set_show_tics(.false.)
197-
198-
! Create the plot
207+
! Initialize the plot
199208
call plt%initialize()
200209
call plt%set_colormap(map)
201210
211+
! Establish lighting
212+
call plt%set_use_lighting(.true.)
213+
214+
! Set the orientation of the plot
215+
call plt%set_elevation(20.0d0)
216+
call plt%set_azimuth(30.0d0)
217+
202218
! Define titles
203219
call plt%set_title("Example Plot")
204-
220+
205221
xAxis => plt%get_x_axis()
206222
call xAxis%set_title("X Axis")
207223
@@ -211,19 +227,20 @@ program example
211227
zAxis => plt%get_z_axis()
212228
call zAxis%set_title("Z Axis")
213229
214-
! Define the data set
230+
! Define the function to plot
231+
z = sqrt(x**2 + y**2) * sin(x**2 + y**2)
215232
call d1%define_data(x, y, z)
216233
call plt%push(d1)
217234
218-
! Let GNUPLOT draw the plot
235+
! Draw the plot
219236
call plt%draw()
220237
end program
221238
```
222239
This is the plot resulting from the above program.
223-
![](images/example_surf_plot_1.png?raw=true)
240+
![](images/custom_colormap.png?raw=true)
224241

225242
## Example 4
226-
The following example illustrates how to create a vector-field plot.
243+
The following example illustrates how to create a vector-field plot. This example illustrates using one of the built-in colormaps to to help illustrate vector magnitude.
227244
```fortran
228245
program example
229246
use iso_fortran_env
@@ -335,22 +352,3 @@ end program
335352
This is the plot resulting from the above program.
336353
![](images/polar_example_1.png?raw=true)
337354

338-
## Building FPLOT
339-
[CMake](https://cmake.org/)This library can be built using CMake. For instructions see [Running CMake](https://cmake.org/runningcmake/).
340-
341-
[FPM](https://github.com/fortran-lang/fpm) can also be used to build this library using the provided fpm.toml.
342-
```txt
343-
fpm build
344-
```
345-
The FPLOT library can be used within your FPM project by adding the following to your fpm.toml file.
346-
```toml
347-
[dependencies]
348-
fplot = { git = "https://github.com/jchristopherson/fplot" }
349-
```
350-
351-
## External Libraries
352-
The FPLOT library depends upon the following libraries.
353-
- [FERROR](https://github.com/jchristopherson/ferror)
354-
- [COLLECTIONS](https://github.com/jchristopherson/collections)
355-
- [ISO_VARYING_STRING](https://gitlab.com/everythingfunctional/iso_varying_string)
356-
- [GEOMPACK](https://github.com/jchristopherson/geompack)

dependencies/CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ add_subdirectory(ferror)
77
set(ferror_LIBRARY ${ferror_LIBRARY} PARENT_SCOPE)
88
set(ferror_INCLUDE_DIR ${ferror_INCLUDE_DIR} PARENT_SCOPE)
99

10-
# Get ISO_VARYING_STRING
11-
add_subdirectory(iso_varying_string)
12-
set(iso_varying_string_LIBRARY ${iso_varying_string_LIBRARY} PARENT_SCOPE)
13-
set(iso_varying_string_INCLUDE_DIR ${iso_varying_string_INCLUDE_DIR} PARENT_SCOPE)
10+
# Get FSTRING
11+
add_subdirectory(fstring)
12+
set(fstring_LIBRARY ${fstring_LIBRARY} PARENT_SCOPE)
13+
set(fstring_INCLUDE_DIR ${fstring_INCLUDE_DIR} PARENT_SCOPE)
1414

1515
# Get COLLECTIONS
1616
add_subdirectory(collections)
@@ -21,3 +21,8 @@ set(collections_INCLUDE_DIR ${collections_INCLUDE_DIR} PARENT_SCOPE)
2121
add_subdirectory(geompack)
2222
set(geompack_LIBRARY ${geompack_LIBRARY} PARENT_SCOPE)
2323
set(geompack_INCLUDE_DIR ${geompack_INCLUDE_DIR} PARENT_SCOPE)
24+
25+
# Get FORCOLORMAP
26+
add_subdirectory(forcolormap)
27+
set(forcolormap_LIBRARY ${forcolormap_LIBRARY} PARENT_SCOPE)
28+
set(forcolormap_INCLUDE_DIR ${forcolormap_INCLUDE_DIR} PARENT_SCOPE)

dependencies/collections/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Get the macros and functions we'll need
2-
include("${PROJECT_SOURCE_DIR}/cmake/helper.cmake")
32
include(FetchContent)
43

54
# Fetch the proper content

dependencies/ferror/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Get the macros and functions we'll need
2-
include("${PROJECT_SOURCE_DIR}/cmake/helper.cmake")
32
include(FetchContent)
43

54
# Fetch the proper content
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Get the macros and functions we'll need
2+
include(FetchContent)
3+
4+
# Fetch the proper content
5+
FetchContent_Declare(
6+
forcolormap
7+
GIT_REPOSITORY "https://github.com/vmagnin/forcolormap"
8+
GIT_TAG main
9+
)
10+
11+
FetchContent_MakeAvailable(forcolormap)
12+
13+
if (WIN32)
14+
if (BUILD_SHARED_LIBS)
15+
add_custom_command(
16+
TARGET ${PROJECT_NAME} POST_BUILD
17+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
18+
$<TARGET_FILE:forcolormap>
19+
$<TARGET_FILE_DIR:${PROJECT_NAME}>
20+
)
21+
endif()
22+
endif()
23+
24+
set(forcolormap_INCLUDE_DIR ${forcolormap_BINARY_DIR}/include)
25+
set(forcolormap_INCLUDE_DIR ${forcolormap_INCLUDE_DIR} PARENT_SCOPE)
26+
27+
# Make a parent-scope variable for the library
28+
set(forcolormap_LIBRARY forcolormap)
29+
set(forcolormap_LIBRARY ${forcolormap_LIBRARY} PARENT_SCOPE)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Get the macros and functions we'll need
2+
include(FetchContent)
3+
4+
# Fetch the proper content
5+
FetchContent_Declare(
6+
fstring
7+
GIT_REPOSITORY "https://github.com/jchristopherson/fstring"
8+
GIT_TAG main
9+
)
10+
11+
FetchContent_MakeAvailable(fstring)
12+
13+
if (WIN32)
14+
if (BUILD_SHARED_LIBS)
15+
add_custom_command(
16+
TARGET ${PROJECT_NAME} POST_BUILD
17+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
18+
$<TARGET_FILE:fstring>
19+
$<TARGET_FILE_DIR:${PROJECT_NAME}>
20+
)
21+
endif()
22+
endif()
23+
24+
set(fstring_INCLUDE_DIR ${fstring_BINARY_DIR}/include)
25+
set(fstring_INCLUDE_DIR ${fstring_INCLUDE_DIR} PARENT_SCOPE)
26+
27+
# Make a parent-scope variable for the library
28+
set(fstring_LIBRARY fstring)
29+
set(fstring_LIBRARY ${fstring_LIBRARY} PARENT_SCOPE)

dependencies/geompack/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Get the macros and functions we'll need
2-
include("${PROJECT_SOURCE_DIR}/cmake/helper.cmake")
32
include(FetchContent)
43

54
# Fetch the proper content

dependencies/iso_varying_string/CMakeLists.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)