Skip to content

Commit

Permalink
give in to the export (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC authored Feb 13, 2018
1 parent 4211f29 commit 43458c7
Show file tree
Hide file tree
Showing 15 changed files with 202 additions and 234 deletions.
38 changes: 15 additions & 23 deletions docs/src/examples/coordinates.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
# Coordinates

```jl
import PGFPlotsX
const pgf = PGFPlotsX
using LaTeXStrings
```

```@setup pgf
import PGFPlotsX
const pgf = PGFPlotsX
using LaTeXStrings
using PGFPlotsX
savefigs = (figname, obj) -> begin
pgf.save(figname * ".pdf", obj)
PGFPlotsX.save(figname * ".pdf", obj)
run(`pdf2svg $(figname * ".pdf") $(figname * ".svg")`)
pgf.save(figname * ".tex", obj);
PGFPlotsX.save(figname * ".tex", obj);
return nothing
end
```
Expand All @@ -24,16 +16,16 @@ For basic usage, consider `AbstractVectors` and iterables. Notice how non-finite

```@example pgf
x = linspace(-1, 1, 51) # so that it contains 1/0
pgf.@pgf pgf.Axis(
@pgf Axis(
{
xmajorgrids,
ymajorgrids,
},
pgf.Plot(
Plot(
{
no_marks,
},
pgf.Coordinates(x, 1 ./ x)
Coordinates(x, 1 ./ x)
)
)
savefigs("coordinates-simple", ans) # hide
Expand All @@ -46,13 +38,13 @@ savefigs("coordinates-simple", ans) # hide
Use `xerror`, `xerrorplus`, `xerrorminus`, `yerror` etc for error bars.
```@example pgf
x = linspace(0, 2π, 20)
pgf.@pgf pgf.Plot(
@pgf Plot(
{
"no marks",
"error bars/y dir=both",
"error bars/y explicit",
},
pgf.Coordinates(x, sin.(x); yerror = 0.2*cos.(x))
Coordinates(x, sin.(x); yerror = 0.2*cos.(x))
)
savefigs("coordinates-errorbars", ans) # hide
```
Expand All @@ -65,11 +57,11 @@ Use three vectors to construct 3D coordinates.

```@example pgf
t = linspace(0, 6*π, 100)
pgf.@pgf pgf.Plot3(
@pgf Plot3(
{
no_marks,
},
pgf.Coordinates(t .* sin.(t), t .* cos.(t), .-t)
Coordinates(t .* sin.(t), t .* cos.(t), .-t)
)
savefigs("coordinates-3d", ans) # hide
```
Expand All @@ -84,11 +76,11 @@ A convenience constructor is available for plotting a matrix of values calculate
x = linspace(-2, 2, 20)
y = linspace(-0.5, 3, 25)
f(x, y) = (1 - x)^2 + 100*(y - x^2)^2
pgf.@pgf pgf.Plot3(
@pgf Plot3(
{
surf,
},
pgf.Coordinates(x, y, f.(x, y'));
Coordinates(x, y, f.(x, y'));
incremental = false
)
savefigs("coordinates-3d-matrix", ans) # hide
Expand All @@ -101,18 +93,18 @@ savefigs("coordinates-3d-matrix", ans) # hide
```@example pgf
x = linspace(-2, 2, 40)
y = linspace(-0.5, 3, 50)
pgf.@pgf pgf.Axis(
@pgf Axis(
{
view = (0, 90),
colorbar,
"colormap/jet",
},
pgf.Plot3(
Plot3(
{
surf,
shader = "flat",
},
pgf.Coordinates(x, y, @. √(f(x, y')));
Coordinates(x, y, @. √(f(x, y')));
incremental = false
)
)
Expand Down
76 changes: 35 additions & 41 deletions docs/src/examples/gallery.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
# PGFPlots manual gallery

Examples converted from [the PGFPlots manual gallery](http://pgfplots.sourceforge.net/gallery.html).
This is a work in progress. All the examples are run with the following code added to them.

```jl
import PGFPlotsX
const pgf = PGFPlotsX
using LaTeXStrings
```
This is a work in progress.

```@setup pgf
import PGFPlotsX
const pgf = PGFPlotsX
using LaTeXStrings
using PGFPlotsX
savefigs = (figname, obj) -> begin
pgf.save(figname * ".pdf", obj)
PGFPlotsX.save(figname * ".pdf", obj)
run(`pdf2svg $(figname * ".pdf") $(figname * ".svg")`)
pgf.save(figname * ".tex", obj);
PGFPlotsX.save(figname * ".tex", obj);
return nothing
end
```
Expand All @@ -25,17 +17,17 @@ end


```@example pgf
pgf.@pgf pgf.Axis(
@pgf Axis(
{
xlabel = "Cost",
ylabel = "Error",
},
pgf.Plot(
Plot(
{
color = "red",
mark = "x"
},
pgf.Coordinates(
Coordinates(
[
(2, -2.8559703),
(3, -3.5301677),
Expand All @@ -58,13 +50,14 @@ savefigs("cost-error", ans) # hide
------------------------

```@example pgf
pgf.@pgf pgf.Axis(
using LaTeXStrings
@pgf Axis(
{
xlabel = L"x",
ylabel = L"f(x) = x^2 - x + 4"
},
pgf.Plot(
pgf.Expression("x^2 - x + 4")
Plot(
Expression("x^2 - x + 4")
)
)
savefigs("simple-expression", ans) # hide
Expand All @@ -77,15 +70,15 @@ savefigs("simple-expression", ans) # hide
------------------------

```@example pgf
pgf.@pgf pgf.Axis(
@pgf Axis(
{
height = "9cm",
width = "9cm",
grid = "major",
},
[
pgf.Plot(pgf.Expression("-x^5 - 242"); label = "model")
pgf.Plot(pgf.Coordinates(
Plot(Expression("-x^5 - 242"); label = "model")
Plot(Coordinates(
[
(-4.77778,2027.60977),
(-3.55556,347.84069),
Expand All @@ -110,19 +103,19 @@ savefigs("cost-gain", ans) # hide
------------------------

```@example pgf
pgf.@pgf pgf.Axis(
@pgf Axis(
{
xlabel = "Cost",
ylabel = "Gain",
xmode = "log",
ymode = "log",
},
pgf.Plot(
Plot(
{
color = "red",
mark = "x"
},
pgf.Coordinates(
Coordinates(
[
(10, 100),
(20, 150),
Expand All @@ -145,18 +138,18 @@ savefigs("cost-gain-log-log", ans) # hide
------------------------

```@example pgf
pgf.@pgf pgf.Axis(
@pgf Axis(
{
xlabel = "Cost",
ylabel = "Gain",
ymode = "log",
},
pgf.Plot(
Plot(
{
color = "blue",
mark = "*"
},
pgf.Coordinates(
Coordinates(
[
(1, 8)
(2, 16)
Expand All @@ -180,39 +173,40 @@ savefigs("cost-gain-ylog", ans) # hide
------------------------

```@example pgf
pgf.@pgf pgf.Axis(
using LaTeXStrings
@pgf Axis(
{
xlabel = "Degrees of freedom",
ylabel = L"$L_2$ Error",
xmode = "log",
ymode = "log",
},
[
pgf.Plot(pgf.Coordinates(
Plot(Coordinates(
[( 5, 8.312e-02), ( 17, 2.547e-02), ( 49, 7.407e-03),
( 129, 2.102e-03), ( 321, 5.874e-04), ( 769, 1.623e-04),
(1793, 4.442e-05), (4097, 1.207e-05), (9217, 3.261e-06),]
)),
pgf.Plot(pgf.Coordinates(
Plot(Coordinates(
[( 7, 8.472e-02), ( 31, 3.044e-02), (111, 1.022e-02),
( 351, 3.303e-03), ( 1023, 1.039e-03), (2815, 3.196e-04),
(7423, 9.658e-05), (18943, 2.873e-05), (47103, 8.437e-06),]
)),
pgf.Plot(pgf.Coordinates(
Plot(Coordinates(
[( 9, 7.881e-02), ( 49, 3.243e-02), ( 209, 1.232e-02),
( 769, 4.454e-03), ( 2561, 1.551e-03), ( 7937, 5.236e-04),
(23297, 1.723e-04), (65537, 5.545e-05), (178177, 1.751e-05),]
)),
pgf.Plot(pgf.Coordinates(
Plot(Coordinates(
[( 11, 6.887e-02), ( 71, 3.177e-02), ( 351, 1.341e-02),
( 1471, 5.334e-03), ( 5503, 2.027e-03), ( 18943, 7.415e-04),
(61183, 2.628e-04), (187903, 9.063e-05), (553983, 3.053e-05),]
)),
pgf.Plot(pgf.Coordinates(
Plot(Coordinates(
[( 13, 5.755e-02), ( 97, 2.925e-02), ( 545, 1.351e-02),
( 2561, 5.842e-03), ( 10625, 2.397e-03), ( 40193, 9.414e-04),
(141569, 3.564e-04), (471041, 1.308e-04), (1496065, 4.670e-05),]
Expand All @@ -229,21 +223,21 @@ savefigs("dof-error", ans) # hide
------------------------

```@example pgf
pgf.@pgf pgf.Axis(
@pgf Axis(
{
"scatter/classes" = {
a = {mark = "square*", "blue"},
b = {mark = "triangle*", "red"},
c = {mark = "o", draw = "black"},
}
},
pgf.Plot(
Plot(
{
scatter,
"only marks",
"scatter src" = "explicit symbolic",
},
pgf.Table(
Table(
{
meta = "label"
},
Expand All @@ -263,19 +257,19 @@ savefigs("table-label", ans) # hide
------------------------

```@example pgf
pgf.@pgf pgf.Axis(
@pgf Axis(
{
"nodes near coords" = raw"(\coordindex)",
title = raw"\texttt{patch type=quadratic spline}",
},
pgf.Plot(
Plot(
{
mark = "*",
patch,
mesh, # without mesh, pgfplots tries to fill,
# "patch type" = "quadratic spline", <- Should work??
},
pgf.Coordinates(
Coordinates(
[
# left, right, middle-> first segment
(0, 0), (1, 1), (0.5, 0.5^2),
Expand All @@ -295,14 +289,14 @@ savefigs("spline-quadratic", ans) # hide
------------------------

```@example pgf
pgf.@pgf pgf.Plot3(
@pgf Plot3(
{
mesh,
scatter,
samples = 10,
domain = 0:1
},
pgf.Expression("x * (1-x) * y * (1-y)")
Expression("x * (1-x) * y * (1-y)")
)
savefigs("mesh-scatter", ans) # hide
```
Expand Down
Loading

0 comments on commit 43458c7

Please sign in to comment.