@@ -445,25 +445,14 @@ function vectorplot!(ctx, TP::Type{UnicodePlotsType}, ::Type{Val{2}}, grid, func
445445 # we need an integer resolution
446446 resolution = @. Int (round (resolution))
447447
448-
449- rasterpoints = round (sum (resolution) / 2 ) # ignores ctx[:rasterpoints]
450- rc, rv = vectorsample (grid, func; gridscale = ctx[:gridscale ], rasterpoints = rasterpoints, offset = ctx[:offset ])
448+ rc, rv = vectorsample (grid, func; gridscale = ctx[:gridscale ], rasterpoints = ((resolution[1 ] - 1 ) / 2 , 2 * (resolution[2 ] - 1 )), offset = ctx[:offset ])
451449 qc, qv = quiverdata (rc, rv; vscale = ctx[:vscale ], vnormalize = ctx[:vnormalize ], vconstant = ctx[:vconstant ])
452450
453-
454- # create UnicodePlots.Canvas
455- if ctx[:colorbar ] != = :none
456- colorbar_width = 3
457- else
458- colorbar_width = 0
459- end
460- padding = 0.05 * (ex[2 ] - ex[1 ])
461- ex = (ex[1 ] - padding, ex[2 ] + padding)
462451 CanvasType = UnicodePlots. BrailleCanvas # should this be a changeable parameter ?
463452 canvas = CanvasType (
464- resolution[2 ], resolution[1 ] + colorbar_width , # number of rows and columns (characters)
465- origin_y = 0 , origin_x = ex[1 ], # position in virtual space
466- height = 1 , width = (ex [2 ] - ex [1 ]) / (resolution [2 ] / (resolution[ 2 ] + colorbar_width) ); blend = false
453+ resolution[2 ], resolution[1 ], # number of rows and columns (characters)
454+ origin_y = ey[ 1 ] , origin_x = ex[1 ], # position in virtual space
455+ height = (ey [2 ] - ey [1 ]), width = (ex [2 ] - ex[ 1 ] ); blend = false
467456 )
468457
469458
@@ -484,9 +473,13 @@ function vectorplot!(ctx, TP::Type{UnicodePlotsType}, ::Type{Val{2}}, grid, func
484473 # plot arrows
485474 scale = minimum (resolution) / maximum (ctx[:rasterpoints ]) / 300
486475 narrows = size (qv, 2 )
487- arrows = [' ↙' , ' ↓' , ' ↘' , ' →' , ' ↗' , ' ↑' , ' ↖' , ' ←' ]
476+ arrows = [' 🡷' , ' 🡳' , ' 🡶' , ' 🡲' , ' 🡵' , ' 🡱' , ' 🡴' , ' 🡰' ]
477+ # arrows = ['↙', '↓', '↘', '→', '↗', '↑', '↖', '←']
478+ # arrows = ['🡯', '🡫', '🡮', '🡪', '🡭', '🡩', '🡬', '🡨']
479+ # arrows = ['⬃', '⇩', '⬂', '⇨', '⬀', '⇧', '⬁', '⇦']
480+ # arrows = ['🢇', '🢃', '🢆', '🢂', '🢅', '🢁', '🢄', '🢀']
481+ # arrows = ['⬋','⬇','⬊','➡','⬈','⬆','⬉','⬅']
488482 maxnorm = maximum (sqrt .(sum (qv .^ 2 , dims = 1 )))
489- draw_stream = false
490483 colormap = colorschemes[ctx[:colormap ]]
491484 for a in 1 : narrows
492485 # calculate angle of arrow
@@ -516,29 +509,12 @@ function vectorplot!(ctx, TP::Type{UnicodePlotsType}, ::Type{Val{2}}, grid, func
516509 end
517510
518511 UnicodePlots. annotate! (canvas, qc[1 , a], qc[2 , a], char, uint_color, false )
519- if draw_stream
520- tx, ty = qc[1 , a] + 0.67 * qv[1 , a], qc[2 , a] + 0.67 * qv[2 , a]
521- UnicodePlots. lines! (
522- canvas,
523- qc[1 , a], qc[2 , a],
524- tx, ty;
525- color = uint_color
526- )
527- end
528- end
529-
530- # # colorbar
531- if ctx[:colorbar ] != = :none
532- for j in 0 : (2 * resolution[2 ] - 7 )
533- scale = j / (2 * resolution[2 ] - 7 )
534- uint_color = UnicodePlots. ansi_color (colormap[scale])
535- UnicodePlots. annotate! (canvas, ex[2 ] + 2 * (ex[2 ] - ex[1 ]) / resolution[2 ], (j + 4 ) * (ey[2 ] - ey[1 ]) / (2 * resolution[2 ]), " ▒▒" , uint_color, false )
536- end
537- ctx[:figure ] = UnicodePlots. Plot (canvas; title = ctx[:title ])
538- UnicodePlots. annotate! (ctx[:figure ], ex[2 ] + 2 * (ex[2 ] - ex[1 ]) / resolution[2 ], ey[1 ], " 0.0 " )
539- UnicodePlots. annotate! (ctx[:figure ], ex[2 ] + 2 * (ex[2 ] - ex[1 ]) / resolution[2 ], ey[2 ], " $(Float16 (maxnorm)) " )
540512 end
541513
514+ plot = UnicodePlots. Plot (canvas; title = ctx[:title ])
515+ plot. cmap. bar = ctx[:colorbar ] == :none ? false : true
516+ plot. cmap. lim = (0 , Float16 (maxnorm))
517+ ctx[:figure ] = plot
542518
543519 return reveal (ctx, TP)
544520end
0 commit comments