-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[WIP] Implement a scattertext plot method. #4063
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
Conversation
Adds a TextCollection object that facilitates drawing a bunch of text with common properties at different locations. scattertext() uses this to plot text in data coordinates, with an optional offset.
👍 For feature. There might also be issues with the |
I am also 👍 on not being worried about performance with this. The ability to easily do broadcasting of interesting properties over artists is one of the places that bokeh is well ahead of us. I wonder if in addition to the def broadcast_magic(ax, Art_cls, **kwargs):
static_kwargs = dict()
broadcast_names = []
max_count = -1
cycle_values = []
for k, v in kwargs.items:
if is_iterable(v) and not is_string(v):
broadcast_name.append(k)
cycle_values = cycle(v)
if len(v) > max_count:
max_count = len(v)
else:
static_kwargs[k] = v
ret = []
for count, b_vals in enumerate(zip(cycle_values)):
if not count <max_count:
break
local_kwargs = dict(static_kwargs)
local_kwargs.update({k: v for k, v in zip(broadcast_names, b_vals)})
art = Art_cls(**local_kwargs)
ax.add_artist(art)
ret.append(art)
return ret |
If you only need |
@OceanWolf I'm lost on your acronym, and strangely, googling it isn't helping. :) |
Artist Style Sheets. It is one of the MEPs. On Mon, Jun 29, 2015 at 2:32 PM, Ryan May notifications@github.com wrote:
|
It's unclear to me if MEP26 is relevant. I want to easily be able to put a bunch of text on a plot, all with the same style (maybe changing color, but that's all). This facilitates plotting many text values (or even just strings) in data coordinates, often offset from the center location. This can certainly be accomplished now directly with a |
This should inherit from |
No objections to this being re-opened, but closing because its been 3 years, and I'm not entirely sure what the advantage is over just having a for-loop to add the text (and creating a list of handles if you want to store them for future reference). I imagine most folks who want this are getting by using this method. |
It's relevant to #5665 (moving ticks to use LineCollections instead of individual lines would (perhaps) logically move label texts to TextCollections as well). But I'm fine leaving this closed for now, we can always revisit it later. |
Adds a TextCollection object that facilitates drawing a bunch of text
with common properties at different locations. scattertext() uses this
to plot text in data coordinates, with an optional offset.
This is a first cut in order to get design feedback. TextCollection inherits only from Text right now, just overriding the draw() method to do multiple calls to draw_text(). The implementation here started with Text.draw(), so there are some things like bbox and PathEffects that are inherited that may or may not make sense.
Questions:
Text
so that the hack forget_layout()
isn't necessaryCollection
cm.ScalarMappable
?scattertext()
: Should it take an array of data values or an array of strings?Any other issues?