File tree Expand file tree Collapse file tree 4 files changed +30
-1
lines changed
Filter options
Expand file tree Collapse file tree 4 files changed +30
-1
lines changed
Original file line number Diff line number Diff line change @@ -823,6 +823,20 @@ def rc_params_from_file(fname, fail_on_error=False):
823
823
# this is the instance used by the matplotlib classes
824
824
rcParams = rc_params ()
825
825
826
+ if rcParams ['examples.directory' ]:
827
+ # paths that are intended to be relative to matplotlib_fname()
828
+ # are allowed for the examples.directory parameter.
829
+ # However, we will need to fully qualify the path because
830
+ # Sphinx requires absolute paths.
831
+ if not os .path .isabs (rcParams ['examples.directory' ]):
832
+ _basedir , _fname = os .path .split (matplotlib_fname ())
833
+ # Sometimes matplotlib_fname() can return relative paths,
834
+ # Also, using realpath() guarentees that Sphinx will use
835
+ # the same path that matplotlib sees (in case of weird symlinks).
836
+ _basedir = os .path .realpath (_basedir )
837
+ _fullpath = os .path .join (_basedir , rcParams ['examples.directory' ])
838
+ rcParams ['examples.directory' ] = _fullpath
839
+
826
840
rcParamsOrig = rcParams .copy ()
827
841
828
842
rcParamsDefault = RcParams ([ (key , default ) for key , (default , converter ) in \
Original file line number Diff line number Diff line change 21
21
import warnings
22
22
from weakref import ref , WeakKeyDictionary
23
23
24
+ import matplotlib
24
25
25
26
import numpy as np
26
27
import numpy .ma as ma
@@ -570,9 +571,17 @@ def get_sample_data(fname, asfileobj=True):
570
571
`mpl-data/sample_data` directory. If *asfileobj* is `True`
571
572
return a file object, otherwise just a file path.
572
573
574
+ Set the rc parameter examples.directory to the directory where we should
575
+ look, if sample_data files are stored in a location different than
576
+ default (which is 'mpl-data/sample_data` at the same level of 'matplotlib`
577
+ Python module files).
578
+
573
579
If the filename ends in .gz, the file is implicitly ungzipped.
574
580
"""
575
- root = os .path .join (os .path .dirname (__file__ ), "mpl-data" , "sample_data" )
581
+ if matplotlib .rcParams ['examples.directory' ]:
582
+ root = matplotlib .rcParams ['examples.directory' ]
583
+ else :
584
+ root = os .path .join (os .path .dirname (__file__ ), "mpl-data" , "sample_data" )
576
585
path = os .path .join (root , fname )
577
586
578
587
if asfileobj :
Original file line number Diff line number Diff line change @@ -617,6 +617,9 @@ def __call__(self, s):
617
617
'keymap.xscale' : [['k' , 'L' ], validate_stringlist ],
618
618
'keymap.all_axes' : ['a' , validate_stringlist ],
619
619
620
+ # sample data
621
+ 'examples.directory' : ['' , str ],
622
+
620
623
# Animation settings
621
624
'animation.writer' : ['ffmpeg' , validate_movie_writer ],
622
625
'animation.codec' : ['mpeg4' , str ],
Original file line number Diff line number Diff line change @@ -423,6 +423,9 @@ text.hinting_factor : 8 # Specifies the amount of softness for hinting in the
423
423
#keymap.xscale : L, k # toggle scaling of x-axes ('log'/'linear')
424
424
#keymap.all_axes : a # enable all axes
425
425
426
+ # Control location of examples data files
427
+ #examples.directory : '' # directory to look in for custom installation
428
+
426
429
###ANIMATION settings
427
430
#animation.writer : ffmpeg # MovieWriter 'backend' to use
428
431
#animation.codec : mp4 # Codec to use for writing movie
You can’t perform that action at this time.
0 commit comments