|
1 | 1 | function initialize!(p, ::Type{PyPlotType})
|
2 | 2 | PyPlot = p.context[:Plotter]
|
3 | 3 | PyPlot.PyObject(PyPlot.axes3D)# see https://github.com/JuliaPy/PyPlot.jl/issues/351
|
| 4 | + PyPlot.rc("font", size = p.context[:fontsize]) |
4 | 5 | if !haskey(p.context, :figure)
|
5 | 6 | res = p.context[:size]
|
6 | 7 | if !isdefined(Main, :PlutoRunner)
|
7 |
| - p.context[:figure] = PyPlot.figure(p.context[:fignumber]; dpi = 50) |
| 8 | + p.context[:figure] = PyPlot.figure(p.context[:fignumber]; dpi = 50, figsize=res./50) |
8 | 9 | else
|
9 |
| - p.context[:figure] = PyPlot.figure(p.context[:fignumber]; dpi = 100) |
| 10 | + p.context[:figure] = PyPlot.figure(p.context[:fignumber]; dpi = 100, figsize=res./100) |
10 | 11 | end
|
11 |
| - p.context[:figure].set_size_inches(res[1] / 100, res[2] / 100; forward = true) |
| 12 | + #p.context[:figure].set_size_inches(res[1] / 100, res[2] / 100, forward = true) |
12 | 13 | for ctx in p.subplots
|
13 | 14 | ctx[:figure] = p.context[:figure]
|
14 | 15 | end
|
@@ -43,6 +44,7 @@ function reveal(ctx::SubVisualizer, TP::Type{PyPlotType})
|
43 | 44 | if ctx[:show] || ctx[:reveal]
|
44 | 45 | reveal(ctx[:GridVisualizer], TP)
|
45 | 46 | end
|
| 47 | + ctx[:GridVisualizer].Plotter.tight_layout() |
46 | 48 | end
|
47 | 49 |
|
48 | 50 | #translate Julia attribute symbols to pyplot-speak
|
@@ -552,6 +554,7 @@ function scalarplot!(ctx, TP::Type{PyPlotType}, ::Type{Val{2}}, grids, parentgri
|
552 | 554 | crange = (crange[1] - eps, crange[1] + eps)
|
553 | 555 | colorlevels = collect(crange[1]:((crange[2]-crange[1])/(1)):crange[2])
|
554 | 556 | else
|
| 557 | + crange = (crange[1] - 1e-16, crange[2] + 1e-16) # avoids rare clipping of last color level |
555 | 558 | colorlevels =
|
556 | 559 | collect(crange[1]:((crange[2]-crange[1])/(ctx[:colorlevels]-1)):crange[2])
|
557 | 560 | end
|
@@ -716,10 +719,10 @@ function vectorplot!(ctx, TP::Type{PyPlotType}, ::Type{Val{2}}, grid, func)
|
716 | 719 | ax.set_aspect(ctx[:aspect])
|
717 | 720 | ax.set_title(ctx[:title])
|
718 | 721 |
|
719 |
| - rc, rv = vectorsample(grid, func; spacing = ctx[:spacing], offset = ctx[:offset]) |
720 |
| - qc, qv = quiverdata(rc, rv; vscale = ctx[:vscale], vnormalize = ctx[:vnormalize]) |
| 722 | + rc, rv = vectorsample(grid, func; spacing = ctx[:spacing], offset = ctx[:offset], xlimits = ctx[:xlimits], ylimits = ctx[:ylimits]) |
| 723 | + qc, qv = quiverdata(rc, rv; vscale = ctx[:vscale], vnormalize = ctx[:vnormalize], vconstant = ctx[:vconstant]) |
721 | 724 |
|
722 |
| - ax.quiver(qc[1, :], qc[2, :], qv[1, :], qv[2, :]) |
| 725 | + ax.quiver(qc[1, :], qc[2, :], qv[1, :], qv[2, :]; color = ctx[:color]) |
723 | 726 | ax.set_xlabel(ctx[:xlabel])
|
724 | 727 | ax.set_ylabel(ctx[:ylabel])
|
725 | 728 |
|
@@ -769,11 +772,11 @@ function streamplot!(ctx, TP::Type{PyPlotType}, ::Type{Val{2}}, grid, func)
|
769 | 772 | xout, yout
|
770 | 773 | end
|
771 | 774 |
|
772 |
| - rc, rv = vectorsample(grid, func; spacing = ctx[:spacing], offset = ctx[:offset]) |
| 775 | + rc, rv = vectorsample(grid, func; spacing = ctx[:spacing], offset = ctx[:offset], xlimits = ctx[:xlimits], ylimits = ctx[:ylimits]) |
773 | 776 |
|
774 | 777 | X, Y = meshgrid(rc)
|
775 | 778 |
|
776 |
| - ax.streamplot(X, Y, rv[1, :, :, 1], rv[2, :, :, 1]; color = ctx[:color]) |
| 779 | + ax.streamplot(X, Y, rv[1, :, :, 1]', rv[2, :, :, 1]'; color = ctx[:color], density = ctx[:density]) |
777 | 780 | ax.set_xlabel(ctx[:xlabel])
|
778 | 781 | ax.set_ylabel(ctx[:ylabel])
|
779 | 782 |
|
|
0 commit comments