Content-Length: 300059 | pFad | http://github.com/fastplotlib/fastplotlib/pull/366/files

7D added colorbar by Neurobiologist · Pull Request #366 · fastplotlib/fastplotlib · GitHub
Skip to content

added colorbar #366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
51 changes: 51 additions & 0 deletions fastplotlib/graphics/legends/colorbar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from .._base import Graphic
from .. import TextGraphic
import pygfx

class CmapLegend(Graphic):
def __init__(
self,
cmap_name: str,
vmin: float,
vmax: float,
width: float,
height: float,
*args,
**kwargs,
):
super().__init__(*args, **kwargs)

wo = pygfx.Group()

cmap = get_cmap(cmap_name)

tex = pygfx.Texture(np.repeat([cmap], 2, axis=0), dim=2)

geometry = pygfx.plane_geometry(width, height, 1, 1)
material = pygfx.MeshBasicMaterial(map=tex)
self._rectangle = pygfx.Mesh(geometry, material)

self._text_vmax = TextGraphic(
text=str(vmax),
size=16,
position=(-width/2, 0),
anchor="center",
outline_color="black",
outline_thickness=1,
)

self._text_vmax.position_x = width/2 + 5

self._text_vmin = TextGraphic(
text=str(vmin),
size=16,
position=(width, 0),
anchor="center",
outline_color="black",
outline_thickness=1,
)

self._text_vmin.position_x = -width/2 - 5

wo.add(self._rectangle, self._text_vmin.world_object, self._text_vmax.world_object)
self._set_world_object(wo)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/fastplotlib/fastplotlib/pull/366/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy