Skip to content

Add example code for current logo #13169

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

Merged
merged 1 commit into from
May 11, 2019
Merged

Add example code for current logo #13169

merged 1 commit into from
May 11, 2019

Conversation

timhoffm
Copy link
Member

@timhoffm timhoffm commented Jan 12, 2019

PR Summary

This adds code for creating a current logo (logo2.png). For the time being I've simply added the code to the existing logo example. We should decide later on the existing example can be removed (because it's an old version) or if we want to keep both.

This will still need some optimizations.

Open issues:

  • I would like the circle to go to the edge of the image. However, there's still a (constant?) margin. It's more obvious for the smaller sizes.
  • Would be good to have an option to generate the full matplotlib logo including the text. Still not sure, what the font is. From what I've checked, it looks a lot like Calibri Bold, but it's a bit slanted. However, it's not Calibri Bold Italic because that one uses another type of "a". Does anybody know more on the font?
  • The bars in logo2.png are not exactly in the same places as in this example. Not sure if that really matters.

For review:

Rendered example from CI

@tacaswell tacaswell added this to the v3.1 milestone Jan 12, 2019
@ImportanceOfBeingErnest
Copy link
Member

Concerning the last point, I think the current logo (the one the matplotlib.org page) looks much nicer. This is mainly due to the orange bars not sitting tight against the 90°, -45° lines, but rather in between or on top. For the example it probably doesn't matter, but if someone is planning to use it for some official thing, I think it might be worth the effort to change it.

Concerning the font, it seems to be Calibri, but modified with a transform (see here)

transform="matrix(1,0,-0.0743587,1,0,0)"

Possibly this can be applied to a TextPath via an Affine2D transform in matplotlib.

@timhoffm
Copy link
Member Author

Concerning the last point, I think the current logo (the one the matplotlib.org page) looks much nicer. This is mainly due to the orange bars not sitting tight against the 90°, -45° lines, but rather in between or on top.

Turns out, the example code got broken because the alignment of barplots changed from 'edge' to 'center' in v2.0. Putting align='edge'restores the bar positions as seen in the logo image. 😃

IMHO the logo itself looks quite good now. Didn't have time to look into the text so far.

plt.savefig('logo_xsmall.png')

##############################################################################
#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can just remove the old stuff? People can always look at our old documentation to find it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the plan. I'll clean up the PR once I've found time to get the text in.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@tacaswell tacaswell modified the milestones: v3.1.0, v3.0-doc, v3.1-doc Feb 24, 2019
@QuLogic
Copy link
Member

QuLogic commented Mar 26, 2019

I don't have Calibri, so I used Carlito instead, with:

@@ -21,10 +22,17 @@ def make_logo(pixels, lw_bars, lw_grid, lw_border, rgrid):
 
     with plt.rc_context({'axes.edgecolor': mpl_blue,
                          'axes.linewidth': lw_border}):
-        fig = plt.figure(figsize=(pixels / dpi, pixels / dpi), dpi=dpi)
+        fig = plt.figure(figsize=(5 * pixels / dpi, pixels / dpi), dpi=dpi)
         fig.patch.set_alpha(0)
 
-        ax = fig.add_axes((0.03, 0.03, .94, .94), projection='polar')
+        fig.text(0.5, 0.5, 'matplotlib', fontsize=pixels * 0.8,
+                 color=mpl_blue, ha='center', va='center',
+                 fontfamily='Carlito', fontstyle='italic', fontweight='bold',
+                 zorder=-10
+        )
+
+        ax = fig.add_axes((0.54, 0.1, .17, 0.8),
+                          projection='polar')
         ax.set_axisbelow(True)
 
         N = 7

and you get something pretty close:
image

Now, Carlito is not the same as Calibri, which has rounder edges and a double-stack 'a', but it's supposed to be metrically equivalent, so you should be able to stick Calibri in and not have to fiddle with the numbers.

@anntzer
Copy link
Contributor

anntzer commented Mar 26, 2019

Looking at the first version of the svg (both the version with text as text and the version with text as paths can be seen at https://github.com/matplotlib/matplotlib/pull/5758/files) it looks like this is calibri bold with "manual" slanting (transform="matrix(1,0,-0.0743587,1,0,0)").

It's too bad Matplotlib's logo is using a non-free font, but heh.

@timhoffm
Copy link
Member Author

Updated the plot with the option to add the "matplotlib" text.

@anntzer Thanks for the hint on the transform. I'm trying to do this with the matplotlib Transforms by

fig.text(..., transform=Affine2D.from_values(1, 0, -0.0743587, 1, 0, 0))

However, the text is not slanted but is shifted.

Without transform:
image

With transfrom:
image

I suspect I'm overriding some default tranform for the fig text here and I should somehow chain these transforms. Unfortunately, I don't understand the transforms well enough :sad:. Can you give me a hint what to do?

@timhoffm timhoffm force-pushed the logo branch 2 times, most recently from 96c8a57 to 7379c40 Compare March 31, 2019 10:46
@ImportanceOfBeingErnest
Copy link
Member

ImportanceOfBeingErnest commented Mar 31, 2019

The transform of a text applies to the anchor point (x,y) of the text. It cannot be used to transform the letters of the text. In my first comment above I suggested to use a TextPath for the transform.

Now it seems the svg coordinate systems is reflected compared to the one used by matplotlib, so the slanting will need a positive instead of a negative angle. This angle seems to be 4.25° (since tan(4.25)=0.0743128).

So in total,

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.textpath import TextPath
from matplotlib.font_manager import FontProperties
from matplotlib.patches import PathPatch
import matplotlib.transforms as mtrans

fig, ax = plt.subplots()
fig.patch.set_alpha(0)

pixels = 300

fp = FontProperties(family='Calibri', weight = 'bold')
path = TextPath((0,0), "matplotlib", size=pixels * 0.8, prop=fp)


angle = 4.25 #degrees
# either
trans = mtrans.Affine2D().from_values(1, 0, np.tan(np.deg2rad(angle)), 1, 0, 0)
# or
trans = mtrans.Affine2D().skew_deg(angle, 0)

patch = PathPatch(path, transform = trans + ax.transData)

ax.add_patch(patch)
ax.set_aspect("equal")
ax.autoscale()

plt.show()

image

@timhoffm
Copy link
Member Author

Note: I've removed all the code for drawing the old logo. I don't think anybody will be interested in this. If so, they can still go back in history in the repo.


Thanks to Tony Yu <tsyu80@gmail.com> for the logo design
Thanks to Tony Yu <tsyu80@gmail.com> for the original logo design.
Copy link
Member Author

@timhoffm timhoffm Apr 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anybody know who has created the current logo?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log for the file goes back to 4d11bf4, so JDH? There's not code there either, so hard to say. Possibly it came from some separate website repo...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, sorry, that's the old logo. The new one was added in #5653 and was apparently the logo shipped as stickers for a year before that. I don't know if it was @mdboom who designed it or someone else.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have moved the original logo credit to the credits page. It's better to collect all credits there and not scatter them throughout the documentation. If anybody wants to add credit for the current logo, please do there.

@timhoffm timhoffm force-pushed the logo branch 2 times, most recently from 0d9af7e to 199fd92 Compare May 1, 2019 13:46
@timhoffm
Copy link
Member Author

timhoffm commented May 1, 2019

For review: Rendered example from CI

Update: Rendered example from CI

Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks a lot for putting this together.

@WeatherGod
Copy link
Member

WeatherGod commented May 9, 2019 via email

@timhoffm
Copy link
Member Author

I have moved the original logo credit to the credits page. It's better to collect all credits there and not scatter them throughout the documentation. If anybody wants to add credit for the current logo, please do there.

@jklymak
Copy link
Member

jklymak commented May 10, 2019

Sorry if I missed discussion above, but the render you link did not find the correct font: Original font not found. The logo text will not be in the correct font.

@anntzer
Copy link
Contributor

anntzer commented May 10, 2019

I think it would be nice to keep the old logo around, e.g. in the history.rst page (which already has an even older logo as well).

@timhoffm
Copy link
Member Author

@jklymak That is correct. The original font would be Calibri, but the font is not publically available in linux and I don't think we can add it to the repo due to copyright.

@jklymak
Copy link
Member

jklymak commented May 10, 2019

But this isn’t even a bold font. You can’t use a font that looks ok?

@timhoffm
Copy link
Member Author

We can use Carlito see here: #13169 (comment)

Probably need to install this package to the doc building server:
https://www.ubuntuupdates.org/package/core/disco/universe/base/fonts-crosextra-carlito

@timhoffm
Copy link
Member Author

timhoffm commented May 11, 2019

Now using Carlito in CI: Rendered example from CI

The history page (CI) now contains the previous logo from this example.

@jklymak jklymak merged commit 8f62234 into matplotlib:master May 11, 2019
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request May 11, 2019
@timhoffm timhoffm deleted the logo branch May 11, 2019 15:19
dstansby added a commit that referenced this pull request May 11, 2019
…169-on-v3.1.x

Backport PR #13169 on branch v3.1.x (Add example code for current logo)
@tacaswell tacaswell modified the milestones: v3.1.1, v3.1.0 May 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants