Minor changes
This commit is contained in:
parent
798e675424
commit
59434a6021
@ -1,9 +1,11 @@
|
|||||||
name = "Gnuplot"
|
name = "Gnuplot"
|
||||||
uuid = "dc211083-a33a-5b79-959f-2ff34033469d"
|
uuid = "dc211083-a33a-5b79-959f-2ff34033469d"
|
||||||
|
version = "1.1.0"
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
|
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
|
||||||
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
|
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
|
||||||
|
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
|
||||||
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
||||||
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
|
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
|
||||||
StructC14N = "d2514e9c-36c4-5b8e-97e2-51e7675c221c"
|
StructC14N = "d2514e9c-36c4-5b8e-97e2-51e7675c221c"
|
||||||
|
|||||||
@ -63,7 +63,7 @@ A named dataset is available until the session is reset, i.e. as long as `:-` is
|
|||||||
|
|
||||||
**Gnuplot.jl** can draw multiple plots in the same figure by exploiting the `multiplot` command. Each plot is identified by a positive integer number, which can be used as argument to `@gp` to redirect commands to the appropriate plot.
|
**Gnuplot.jl** can draw multiple plots in the same figure by exploiting the `multiplot` command. Each plot is identified by a positive integer number, which can be used as argument to `@gp` to redirect commands to the appropriate plot.
|
||||||
|
|
||||||
Continuing previous example we can plot both data and best fit model (in plot `1`) and residuals (in plot `2`):
|
Continuing with the previous example we can plot both data and best fit model (in plot `1`) and residuals (in plot `2`):
|
||||||
```@example abc
|
```@example abc
|
||||||
@gp :- "set multiplot layout 2,1"
|
@gp :- "set multiplot layout 2,1"
|
||||||
@gp :- 1 "p $name w errorbars t 'Data'"
|
@gp :- 1 "p $name w errorbars t 'Data'"
|
||||||
@ -181,7 +181,7 @@ saveas("ex014c") # hide
|
|||||||
|
|
||||||
|
|
||||||
## Contour lines
|
## Contour lines
|
||||||
Although gnuplot already handles contours by itself (with the `set contour` command), **Gnuplot.jl** provides a way to calculate contour lines paths before displaying them, using the [`contourlines()`](@ref) function. We may use it for, e.g., plot contour lines with customized widths and palette, according to their z level. Continuing previous example:
|
Although gnuplot already handles contours by itself (with the `set contour` command), **Gnuplot.jl** provides a way to calculate contour lines paths before displaying them, using the [`contourlines()`](@ref) function. We may use it for, e.g., plot contour lines with customized widths and palette, according to their z level. Continuing with the previous example:
|
||||||
```@example abc
|
```@example abc
|
||||||
clines = contourlines(h.bins1, h.bins2, h.counts, cntrparam="levels discrete 10, 30, 60, 90");
|
clines = contourlines(h.bins1, h.bins2, h.counts, cntrparam="levels discrete 10, 30, 60, 90");
|
||||||
for i in 1:length(clines)
|
for i in 1:length(clines)
|
||||||
@ -200,7 +200,7 @@ The [Multiplot](@ref) capabilities can also be used to stack plots one above the
|
|||||||
x = y = -10:0.33:10
|
x = y = -10:0.33:10
|
||||||
fz(x,y) = sin.(sqrt.(x.^2 + y.^2))./sqrt.(x.^2+y.^2)
|
fz(x,y) = sin.(sqrt.(x.^2 + y.^2))./sqrt.(x.^2+y.^2)
|
||||||
fxy = [fz(x,y) for x in x, y in y]
|
fxy = [fz(x,y) for x in x, y in y]
|
||||||
@gsp "set xyplane at 0" "unset colorbox" cb=[-1,1] zr=[-1,1]
|
@gsp "set xyplane at 0" "unset colorbox" cbr=[-1,1] zr=[-1,1]
|
||||||
frame = 0
|
frame = 0
|
||||||
for direction in [-1,1]
|
for direction in [-1,1]
|
||||||
for factor in -1:0.1:1
|
for factor in -1:0.1:1
|
||||||
@ -278,4 +278,3 @@ gpexec("set term unknown")
|
|||||||
- `bin`: provides best performances for large datasets, but uses temporary files;
|
- `bin`: provides best performances for large datasets, but uses temporary files;
|
||||||
- `text`: may be slow for large datasets, but no temporary file is involved;
|
- `text`: may be slow for large datasets, but no temporary file is involved;
|
||||||
- `auto` (default) automatically choose the best strategy.
|
- `auto` (default) automatically choose the best strategy.
|
||||||
|
|
||||||
|
|||||||
@ -68,6 +68,8 @@ saveas("ex002") # hide
|
|||||||
saveas("ex003") # hide
|
saveas("ex003") # hide
|
||||||
```
|
```
|
||||||

|

|
||||||
|
!!! note
|
||||||
|
The trailing `:-` symbol means the plot will not be updated until the last statement.
|
||||||
|
|
||||||
|
|
||||||
### Send data from Julia to gnuplot:
|
### Send data from Julia to gnuplot:
|
||||||
@ -117,6 +119,7 @@ In order to avoid typing long, and very frequently used gnuplot commands, **Gnup
|
|||||||
- `xlabel="..."` => `"set xlabel \"...\""`;
|
- `xlabel="..."` => `"set xlabel \"...\""`;
|
||||||
- `ylabel="..."` => `"set ylabel \"...\""`;
|
- `ylabel="..."` => `"set ylabel \"...\""`;
|
||||||
- `zlabel="..."` => `"set zlabel \"...\""`;
|
- `zlabel="..."` => `"set zlabel \"...\""`;
|
||||||
|
- `cblabel="..."` => `"set cblabel \"...\""`;
|
||||||
- `xlog=true` => `set logscale x`;
|
- `xlog=true` => `set logscale x`;
|
||||||
- `ylog=true` => `set logscale y`;
|
- `ylog=true` => `set logscale y`;
|
||||||
- `zlog=true` => `set logscale z`;
|
- `zlog=true` => `set logscale z`;
|
||||||
@ -162,7 +165,7 @@ saveas("ex007b") # hide
|
|||||||
To display a gray image use `with image` in place of `with rgbimage`, e.g.:
|
To display a gray image use `with image` in place of `with rgbimage`, e.g.:
|
||||||
```@example abc
|
```@example abc
|
||||||
img = testimage("walkbridge");
|
img = testimage("walkbridge");
|
||||||
@gp palette(:lapaz) "set size square" "set autoscale fix" img "rotate=-0.5pi with image notit"
|
@gp palette(:viridis) "set size square" "set autoscale fix" img "rotate=-0.5pi with image notit"
|
||||||
saveas("ex007c") # hide
|
saveas("ex007c") # hide
|
||||||
```
|
```
|
||||||

|

|
||||||
@ -233,7 +236,7 @@ Note that you can pass both the terminal name and its options via the `term=` ke
|
|||||||
## Gnuplot scripts
|
## Gnuplot scripts
|
||||||
Besides exporting plots in a file **Gnuplot.jl** can also save a *script*, i.e. a file containing the minimum set of data and commands required to re-create a figure using just gnuplot.
|
Besides exporting plots in a file **Gnuplot.jl** can also save a *script*, i.e. a file containing the minimum set of data and commands required to re-create a figure using just gnuplot.
|
||||||
|
|
||||||
To generate a script for one of the example above use:
|
To generate a script for one of the examples above use:
|
||||||
```julia
|
```julia
|
||||||
save("script.gp")
|
save("script.gp")
|
||||||
```
|
```
|
||||||
|
|||||||
@ -41,7 +41,7 @@ A powerful plotting framework is among the most important tool in the toolbox of
|
|||||||
|
|
||||||
Unlike other packages **Gnuplot.jl** is not a pure Julia solution as it depends on an external package to actually generate plots. However, if gnuplot is not available on a given platform, the package could still be used in "*dry*" mode, and no error for a missing dependency will be raised (see [Dry sessions](@ref)).
|
Unlike other packages **Gnuplot.jl** is not a pure Julia solution as it depends on an external package to actually generate plots. However, if gnuplot is not available on a given platform, the package could still be used in "*dry*" mode, and no error for a missing dependency will be raised (see [Dry sessions](@ref)).
|
||||||
|
|
||||||
The **Gnuplot.jl** package development follows a minimalistic approach: it is essentially a thin layer to send data and commands to gnuplot. This way all underlying capabilities, both present and future ones, are automatically exposed to Julia user, with no need to implement dedicated wrappers.
|
The **Gnuplot.jl** package development follows a minimalistic approach: it is essentially a thin layer to send data and commands to gnuplot. This way all underlying capabilities, both present and future ones, are automatically exposed to the Julia user, with no need to implement dedicated wrappers.
|
||||||
|
|
||||||
The functionalities 1, 2 and 3 listed above are similar to those provided by the [Gaston](https://github.com/mbaz/Gaston.jl) package. **Gnuplot.jl** also provides features 4 and 5, as well as the minimalistic approach.
|
The functionalities 1, 2 and 3 listed above are similar to those provided by the [Gaston](https://github.com/mbaz/Gaston.jl) package. **Gnuplot.jl** also provides features 4 and 5, as well as the minimalistic approach.
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ Any modern plotting package is able to produce a simple scatter plot, with custo
|
|||||||
|
|
||||||
**Gnuplot.jl** aims to be ready for even the most challenging plots by relying on the widely and long lasting used gnuplot application, and by allowing each native feature (both present and future ones) to be immediately available in the Julia language. Moreover, **Gnuplot.jl** provides a unique syntax specifically aimed to increase productivity while performing interactive data exploration.
|
**Gnuplot.jl** aims to be ready for even the most challenging plots by relying on the widely and long lasting used gnuplot application, and by allowing each native feature (both present and future ones) to be immediately available in the Julia language. Moreover, **Gnuplot.jl** provides a unique syntax specifically aimed to increase productivity while performing interactive data exploration.
|
||||||
|
|
||||||
Last but not least, have a look at the **Gnuplot.jl** [Examples](#ref) page.
|
Last but not least, have a look at the **Gnuplot.jl** [Examples](@ref) page.
|
||||||
|
|
||||||
|
|
||||||
## Notation
|
## Notation
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
module Gnuplot
|
module Gnuplot
|
||||||
|
|
||||||
using StatsBase, ColorSchemes, ColorTypes, StructC14N, DataStructures
|
using StatsBase, ColorSchemes, ColorTypes, Colors, StructC14N, DataStructures
|
||||||
|
|
||||||
import Base.reset
|
import Base.reset
|
||||||
import Base.write
|
import Base.write
|
||||||
@ -1037,7 +1037,7 @@ end
|
|||||||
|
|
||||||
Return the **Gnuplot.jl** package version.
|
Return the **Gnuplot.jl** package version.
|
||||||
"""
|
"""
|
||||||
version() = v"1.0-dev"
|
version() = v"1.1.0"
|
||||||
|
|
||||||
# ---------------------------------------------------------------------
|
# ---------------------------------------------------------------------
|
||||||
"""
|
"""
|
||||||
@ -1150,6 +1150,7 @@ The `@gp` macro, and its companion `@gsp` for 3D plots, allows to send data and
|
|||||||
- `xlabel="..."` => `"set xlabel \"...\""`;
|
- `xlabel="..."` => `"set xlabel \"...\""`;
|
||||||
- `ylabel="..."` => `"set ylabel \"...\""`;
|
- `ylabel="..."` => `"set ylabel \"...\""`;
|
||||||
- `zlabel="..."` => `"set zlabel \"...\""`;
|
- `zlabel="..."` => `"set zlabel \"...\""`;
|
||||||
|
- `cblabel="..."` => `"set cblabel \"...\""`;
|
||||||
- `xlog=true` => `set logscale x`;
|
- `xlog=true` => `set logscale x`;
|
||||||
- `ylog=true` => `set logscale y`;
|
- `ylog=true` => `set logscale y`;
|
||||||
- `zlog=true` => `set logscale z`.
|
- `zlog=true` => `set logscale z`.
|
||||||
@ -1305,7 +1306,7 @@ function linetypes(cmap::ColorScheme; rev=false)
|
|||||||
else
|
else
|
||||||
color = cmap.colors[i]
|
color = cmap.colors[i]
|
||||||
end
|
end
|
||||||
push!(out, "set linetype $i lc rgb '#" * Base.hex(color))
|
push!(out, "set linetype $i lc rgb '#" * Colors.hex(color))
|
||||||
end
|
end
|
||||||
return join(out, "\n") * "\nset linetype cycle " * string(length(cmap.colors)) * "\n"
|
return join(out, "\n") * "\nset linetype cycle " * string(length(cmap.colors)) * "\n"
|
||||||
end
|
end
|
||||||
@ -1328,7 +1329,7 @@ function palette(cmap::ColorScheme; rev=false)
|
|||||||
else
|
else
|
||||||
color = get(cmap, x)
|
color = get(cmap, x)
|
||||||
end
|
end
|
||||||
push!(levels, "$x '#" * Base.hex(color) * "'")
|
push!(levels, "$x '#" * Colors.hex(color) * "'")
|
||||||
end
|
end
|
||||||
return "set palette defined (" * join(levels, ", ") * ")\nset palette maxcol $(length(cmap.colors))\n"
|
return "set palette defined (" * join(levels, ", ") * ")\nset palette maxcol $(length(cmap.colors))\n"
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user