Skip to content

Native and Backends versatile fullscreen command #17710

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 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4611bff
Backport PR #17667: Don't linewrap css in svg header.
timhoffm Jun 18, 2020
9851a8f
Backport PR #17668: Don't pass "wrong" `indent=False` in SVG generation.
timhoffm Jun 18, 2020
68d0e81
Merge pull request #17671 from meeseeksmachine/auto-backport-of-pr-17…
tacaswell Jun 18, 2020
5d1f4d3
Merge pull request #17672 from meeseeksmachine/auto-backport-of-pr-17…
tacaswell Jun 18, 2020
0dc4c29
Backport PR #17664: Clarify docs of AutoDateLocator.intervald
QuLogic Jun 18, 2020
db5c100
Backport PR #17665: Document that some single char colors are shaded
QuLogic Jun 18, 2020
e72d0cf
Backport PR #17675: DOC: specify that the LaTeX installation needs to…
timhoffm Jun 18, 2020
e419071
Merge pull request #17679 from meeseeksmachine/auto-backport-of-pr-17…
QuLogic Jun 19, 2020
ee341ea
Merge pull request #17678 from meeseeksmachine/auto-backport-of-pr-17…
QuLogic Jun 19, 2020
72d0270
Merge pull request #17677 from meeseeksmachine/auto-backport-of-pr-17…
QuLogic Jun 19, 2020
151f5a0
Backport PR #17676: FIX: correctly process the tick label size
anntzer Jun 19, 2020
060dd59
Merge pull request #17688 from meeseeksmachine/auto-backport-of-pr-17…
tacaswell Jun 19, 2020
50da689
Backport PR #17680: MNT: migrate away from deprecated c-api
WeatherGod Jun 20, 2020
393a101
Merge pull request #17692 from meeseeksmachine/auto-backport-of-pr-17…
QuLogic Jun 20, 2020
bcbde51
Backport PR #17686: Fix tooltip for wx toolbar.
timhoffm Jun 20, 2020
61276cd
Merge pull request #17698 from meeseeksmachine/auto-backport-of-pr-17…
QuLogic Jun 20, 2020
44d9c53
Backport PR #17687: Mention keyboard modifiers in toolbar tooltip texts.
jklymak Jun 20, 2020
2199e3e
Merge pull request #17701 from meeseeksmachine/auto-backport-of-pr-17…
jklymak Jun 20, 2020
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
6 changes: 4 additions & 2 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ etc., you can install the following:
* `ffmpeg <https://www.ffmpeg.org/>`_: for saving movies.
* `ImageMagick <https://www.imagemagick.org/script/index.php>`_: for saving
animated gifs.
* `LaTeX <https://miktex.org/>`_ and `GhostScript (>=9.0)
<https://ghostscript.com/download/>`_ : for rendering text with LaTeX.
* `LaTeX <https://www.latex-project.org/>`_ (with `cm-super
<https://ctan.org/pkg/cm-super>`__ ) and `GhostScript (>=9.0)
<https://ghostscript.com/download/>`_ : for rendering text with
LaTeX.
* `fontconfig <https://www.fontconfig.org>`_ (>= 2.7): for detection of system
fonts on Linux.

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ def _get_tick_label_size(self, axis_name):
tick_kw = self._major_tick_kw
size = tick_kw.get('labelsize',
mpl.rcParams[f'{axis_name}tick.labelsize'])
return mtext.FontProperties(size).get_size_in_points()
return mtext.FontProperties(size=size).get_size_in_points()

def _copy_tick_props(self, src, dest):
"""Copy the properties from *src* tick to *dest* tick."""
Expand Down
8 changes: 6 additions & 2 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2818,8 +2818,12 @@ class NavigationToolbar2:
('Back', 'Back to previous view', 'back', 'back'),
('Forward', 'Forward to next view', 'forward', 'forward'),
(None, None, None, None),
('Pan', 'Pan axes with left mouse, zoom with right', 'move', 'pan'),
('Zoom', 'Zoom to rectangle', 'zoom_to_rect', 'zoom'),
('Pan',
'Left button pans, Right button zooms\n'
'x/y fixes axis, CTRL fixes aspect',
'move', 'pan'),
('Zoom', 'Zoom to rectangle\nx/y fixes axis, CTRL fixes aspect',
'zoom_to_rect', 'zoom'),
('Subplots', 'Configure subplots', 'subplots', 'configure_subplots'),
(None, None, None, None),
('Save', 'Save the figure', 'filesave', 'save_figure'),
Expand Down
7 changes: 6 additions & 1 deletion lib/matplotlib/backends/backend_macosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,13 @@ class NavigationToolbar2Mac(_macosx.NavigationToolbar2, NavigationToolbar2):

def __init__(self, canvas):
self.canvas = canvas # Needed by the _macosx __init__.
data_path = cbook._get_data_path('images')
_, tooltips, image_names, _ = zip(*NavigationToolbar2.toolitems)
_macosx.NavigationToolbar2.__init__(
self, str(cbook._get_data_path('images')))
self,
tuple(str(data_path / image_name) + ".pdf"
for image_name in image_names if image_name is not None),
tuple(tooltip for tooltip in tooltips if tooltip is not None))
NavigationToolbar2.__init__(self, canvas)

def draw_rubberband(self, event, x0, y0, x1, y1):
Expand Down
12 changes: 5 additions & 7 deletions lib/matplotlib/backends/backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def _write_metadata(self, metadata):
writer = self.writer

if 'Title' in metadata:
writer.element('title', text=metadata['Title'], indent=False)
writer.element('title', text=metadata['Title'])

# Special handling.
date = metadata.get('Date', None)
Expand Down Expand Up @@ -387,7 +387,7 @@ def _write_metadata(self, metadata):
'identifier', 'language', 'relation', 'source']:
info = metadata.pop(key.title(), None)
if info is not None:
writer.element(f'dc:{key}', text=info, indent=False)
writer.element(f'dc:{key}', text=info)

# Multiple Agent values.
for key in ['creator', 'contributor', 'publisher', 'rights']:
Expand All @@ -401,7 +401,7 @@ def _write_metadata(self, metadata):
writer.start(f'dc:{key}')
for agent in agents:
writer.start('cc:Agent')
writer.element('dc:title', text=agent, indent=False)
writer.element('dc:title', text=agent)
writer.end('cc:Agent')
writer.end(f'dc:{key}')

Expand All @@ -414,7 +414,7 @@ def _write_metadata(self, metadata):
writer.start('dc:subject')
writer.start('rdf:Bag')
for keyword in keywords:
writer.element('rdf:li', text=keyword, indent=False)
writer.element('rdf:li', text=keyword)
writer.end('rdf:Bag')
writer.end('dc:subject')

Expand All @@ -430,9 +430,7 @@ def _write_default_style(self):
'stroke-linejoin': 'round',
'stroke-linecap': 'butt'})
writer.start('defs')
writer.start('style', type='text/css')
writer.data('*{%s}\n' % default_style)
writer.end('style')
writer.element('style', type='text/css', text='*{%s}' % default_style)
writer.end('defs')

def _make_id(self, type, content):
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ def __init__(self, canvas):
-1,
bitmap=self._icon(f"{image_file}.png"),
bmpDisabled=wx.NullBitmap,
label=text, shortHelp=text, longHelp=tooltip_text,
label=text, shortHelp=tooltip_text,
kind=(wx.ITEM_CHECK if text in ["Pan", "Zoom"]
else wx.ITEM_NORMAL))
.Id)
Expand Down
14 changes: 10 additions & 4 deletions lib/matplotlib/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,14 +1215,14 @@ class AutoDateLocator(DateLocator):
----------
intervald : dict

Mapping of tick frequencies (a constant from dateutil.rrule) to
multiples allowed for that ticking. The default looks like this::
Mapping of tick frequencies to multiples allowed for that ticking.
The default is ::

self.intervald = {
YEARLY : [1, 2, 4, 5, 10, 20, 40, 50, 100, 200, 400, 500,
1000, 2000, 4000, 5000, 10000],
MONTHLY : [1, 2, 3, 4, 6],
DAILY : [1, 2, 3, 7, 14],
DAILY : [1, 2, 3, 7, 14, 21],
HOURLY : [1, 2, 3, 4, 6, 12],
MINUTELY: [1, 5, 10, 15, 30],
SECONDLY: [1, 5, 10, 15, 30],
Expand All @@ -1231,10 +1231,16 @@ class AutoDateLocator(DateLocator):
100000, 200000, 500000, 1000000],
}

where the keys are defined in `dateutil.rrule`.

The interval is used to specify multiples that are appropriate for
the frequency of ticking. For instance, every 7 days is sensible
for daily ticks, but for minutes/seconds, 15 or 30 make sense.
You can customize this dictionary by doing::

When customizing, you should only modify the values for the existing
keys. You should not add or delete entries.

Example for forcing ticks every 3 hours::

locator = AutoDateLocator()
locator.intervald[HOURLY] = [3] # only show every 3 hours
Expand Down
21 changes: 18 additions & 3 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
import matplotlib as mpl
from matplotlib.testing.decorators import (
image_comparison, check_figures_equal, remove_ticks_and_titles)
import matplotlib.pyplot as plt
import matplotlib.markers as mmarkers
import matplotlib.patches as mpatches
import matplotlib.colors as mcolors
import matplotlib.dates as mdates
import matplotlib.font_manager as mfont_manager
import matplotlib.markers as mmarkers
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import matplotlib.transforms as mtransforms
from numpy.testing import (
Expand Down Expand Up @@ -6322,3 +6323,17 @@ def test_autoscale_tiny_sticky():
ax.bar(0, 1e-9)
fig.canvas.draw()
assert ax.get_ylim() == (0, 1.05e-9)


@pytest.mark.parametrize('size', [size for size in mfont_manager.font_scalings
if size is not None] + [8, 10, 12])
@pytest.mark.style('default')
def test_relative_ticklabel_sizes(size):
mpl.rcParams['xtick.labelsize'] = size
mpl.rcParams['ytick.labelsize'] = size
fig, ax = plt.subplots()
fig.canvas.draw()

for name, axis in zip(['x', 'y'], [ax.xaxis, ax.yaxis]):
for tick in axis.get_major_ticks():
assert tick.label1.get_size() == axis._get_tick_label_size(name)
43 changes: 15 additions & 28 deletions src/_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -1108,8 +1108,6 @@ -(void)save_figure:(id)sender

self->height = height;

const char* basedir;

obj = PyObject_GetAttrString((PyObject*)self, "canvas");
if (obj==NULL)
{
Expand All @@ -1130,8 +1128,6 @@ -(void)save_figure:(id)sender
return -1;
}

if(!PyArg_ParseTuple(args, "s", &basedir)) return -1;

NSRect bounds = [view bounds];
NSWindow* window = [view window];

Expand All @@ -1141,35 +1137,24 @@ -(void)save_figure:(id)sender
bounds.size.height += height;
[window setContentSize: bounds.size];

NSString* dir = [NSString stringWithCString: basedir
encoding: NSASCIIStringEncoding];
const char* images[7];
const char* tooltips[7];
if (!PyArg_ParseTuple(args, "(sssssss)(sssssss)",
&images[0], &images[1], &images[2], &images[3],
&images[4], &images[5], &images[6],
&tooltips[0], &tooltips[1], &tooltips[2], &tooltips[3],
&tooltips[4], &tooltips[5], &tooltips[6])) {
return -1;
}

NSButton* buttons[7];

NSString* images[7] = {@"home.pdf",
@"back.pdf",
@"forward.pdf",
@"move.pdf",
@"zoom_to_rect.pdf",
@"subplots.pdf",
@"filesave.pdf"};

NSString* tooltips[7] = {@"Reset original view",
@"Back to previous view",
@"Forward to next view",
@"Pan axes with left mouse, zoom with right",
@"Zoom to rectangle",
@"Configure subplots",
@"Save the figure"};

SEL actions[7] = {@selector(home:),
@selector(back:),
@selector(forward:),
@selector(pan:),
@selector(zoom:),
@selector(configure_subplots:),
@selector(save_figure:)};

NSButtonType buttontypes[7] = {NSMomentaryLightButton,
NSMomentaryLightButton,
NSMomentaryLightButton,
Expand All @@ -1194,9 +1179,11 @@ -(void)save_figure:(id)sender
rect.origin.x = gap;
rect.origin.y = 0.5*(height - rect.size.height);

for (i = 0; i < 7; i++)
{
NSString* filename = [dir stringByAppendingPathComponent: images[i]];
for (i = 0; i < 7; i++) {
NSString* filename = [NSString stringWithCString: images[i]
encoding: NSUTF8StringEncoding];
NSString* tooltip = [NSString stringWithCString: tooltips[i]
encoding: NSUTF8StringEncoding];
NSImage* image = [[NSImage alloc] initWithContentsOfFile: filename];
buttons[i] = [[NSButton alloc] initWithFrame: rect];
[image setSize: size];
Expand All @@ -1205,7 +1192,7 @@ -(void)save_figure:(id)sender
[buttons[i] setImage: image];
[buttons[i] scaleUnitSquareToSize: scale];
[buttons[i] setImagePosition: NSImageOnly];
[buttons[i] setToolTip: tooltips[i]];
[buttons[i] setToolTip: tooltip];
[[window contentView] addSubview: buttons[i]];
[buttons[i] release];
[image release];
Expand Down
5 changes: 2 additions & 3 deletions src/ft2font_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,11 +635,10 @@ static PyObject *PyFT2Font_set_text(PyFT2Font *self, PyObject *args, PyObject *k
size_t size;

if (PyUnicode_Check(textobj)) {
size = PyUnicode_GET_SIZE(textobj);
size = PyUnicode_GET_LENGTH(textobj);
codepoints.resize(size);
Py_UNICODE *unistr = PyUnicode_AsUnicode(textobj);
for (size_t i = 0; i < size; ++i) {
codepoints[i] = unistr[i];
codepoints[i] = PyUnicode_ReadChar(textobj, i);
}
} else if (PyBytes_Check(textobj)) {
size = PyBytes_Size(textobj);
Expand Down
8 changes: 5 additions & 3 deletions tutorials/colors/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
case-insensitive);
* a string representation of a float value in ``[0, 1]`` inclusive for gray
level (e.g., ``'0.5'``);
* one of ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``, they are the single
character short-hand notations for blue, green, red, cyan, magenta, yellow,
black, and white.
* one of the characters ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``, which
are short-hand notations for shades of blue, green, red, cyan, magenta,
yellow, black, and white. Note that the colors ``'g', 'c', 'm', 'y'`` do not
coincide with the X11/CSS4 colors. Their particular shades were chosen for
better visibility of colored lines against typical backgrounds.
* a X11/CSS4 color name (case-insensitive);
* a name from the `xkcd color survey`_, prefixed with ``'xkcd:'`` (e.g.,
``'xkcd:sky blue'``; case insensitive);
Expand Down