Skip to content
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

'multialign' is a text property in mpl when *newlines* are present. #53

Merged
merged 4 commits into from
Jul 3, 2014

Conversation

theengineear
Copy link
Contributor

multiple-line annotations will now be tracekd properly in Plotly

Fixes #49

multiple-line annotations will now be tracekd properly in Plotly
@theengineear
Copy link
Contributor Author

h/o, probably need to update our tests...

@etpinard
Copy link
Contributor

etpinard commented Jul 3, 2014

Hmm.

Off the issue-49 branch:

dataviz1 = plt.figure(...)
dataviz1_plotly = tls.mpl_to_plotly(dataviz1)
dataviz1_plotly['layout']['annotations'][i]['align']  # --> 'center' for all i's

Randal made his source and info annotation using

text(1966, -8, "Data source: nces.ed.gov/programs/digest/2013menu_tables.asp"  
       "\nAuthor: Randy Olson (randalolson.com / @randal_olson)"  
       "\nNote: Some majors are missing because the historical data "  
       "is not available for them", fontsize=10)

which generated a left-align multi-line annotation (see here)

This suggests that mpl multi-line annotations are in fact left-aligned; hence, the plotly convention should include 'align': 'text' in the corresponding annotation object.

@theengineear
Copy link
Contributor Author

haha, oh man! it's a weird default for mpl. if you specify that you want the 'center' the surrounding box and don't specify that the multialignment, the default is indeed 'center' as i had. HOWEVER, if you don't specify the horizontalalignment as is the case in your example, it seems that mpl defaults to 'left', woof!

@theengineear
Copy link
Contributor Author

@etpinard, correction, looks like it defaults to horizontalalignment when unspecified. that should fix it. although, again i probably have to change a test or two to catch up!

@theengineear
Copy link
Contributor Author

k, good to go!

@etpinard
Copy link
Contributor

etpinard commented Jul 3, 2014

Nice! 👍

theengineear added a commit that referenced this pull request Jul 3, 2014
'multialign' is a text property in mpl when *newlines* are present.
@theengineear theengineear merged commit 9c07c32 into master Jul 3, 2014
@theengineear theengineear deleted the issue-49 branch July 3, 2014 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

matplotlylib - left align multi-line annotations
2 participants