-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
adding keyword plotting #8566
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
adding keyword plotting #8566
Changes from 2 commits
File filter
Filter by extension
8000 Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ body { | |
} | ||
|
||
a { | ||
color: #CA7900; | ||
color: #CA7900 !important; | ||
text-decoration: none; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
extensions = ['matplotlib.sphinxext.mathmpl', 'sphinxext.math_symbol_table', | ||
'sphinx.ext.autodoc', 'matplotlib.sphinxext.only_directives', | ||
'sphinx.ext.doctest', 'sphinx.ext.autosummary', | ||
'sphinx.ext.inheritance_diagram', | ||
'sphinx.ext.inheritance_diagram', 'sphinx.ext.intersphinx', | ||
'sphinx_gallery.gen_gallery', | ||
'matplotlib.sphinxext.plot_directive', | ||
'sphinxext.github', | ||
|
@@ -88,6 +88,13 @@ def _check_deps(): | |
|
||
autodoc_docstring_signature = True | ||
|
||
intersphinx_mapping = { | ||
'python': ('https://docs.python.org/', None), | ||
'numpy': ('https://docs.scipy.org/doc/numpy/', None), | ||
'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None), | ||
'pandas': ('https://pandas.pydata.org/pandas-docs/stable', None) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one's not accessible over https, unfortunately. Also, why two-space indent? |
||
} | ||
|
||
|
||
# Sphinx gallery configuration | ||
sphinx_gallery_conf = { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
====================== | ||
Plotting with keywords | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should have a line of |
||
====================== | ||
|
||
There are some instances where you have data in a format that lets you | ||
access particular variables with strings. For example, with | ||
:class:`numpy.recarray` or :class:`pandas.DataFrame`. | ||
|
||
Matplotlib allows you provide such an object with | ||
the ``data`` keyword argument. If provided, then you may generate plots with | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Slightly over-eager wrapping. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do you mean? Doesn't this need to be double ticks since it's rST? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean the line above this is wrapped at like 50 chars instead of 79. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh - ok I removed the extra whitespace. is that such a big deal? I prefer to have extra whitespace as it makes it easier to reword etc without having to bump everything down a bunch of lines There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, it's not major, but I just think it looks odd when one line is broken much earlier than the rest; it didn't even break at the end of a sentence. |
||
the strings corresponding to these variables. | ||
""" | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
np.random.seed(19680801) | ||
|
||
data = dict([('a', np.arange(50)), | ||
('c', np.random.randint(0, 50, 50)), | ||
('d', np.random.randn(50))]) | ||
data['b'] = data['a'] + 10 * np.random.randn(50) | ||
data['d'] = np.abs(data['d']) * 100 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, as much as it's more work in some ways, I feel like an example with a clear structure, so something like: data = { 'a' : [1,2,3,4,5,5,6,7],
'b' :[4,5, 6,2,3, 4, 5],
'c': [3,1,2,3,4,5,6,3],
'd':[1,2,3,4,5,6,7,8]} might work better since the point of this is to really clearly see what the kwarg does. |
||
|
||
fig, ax = plt.subplots() | ||
ax.scatter('a', 'b', c='c', s='d', data=data) | ||
ax.set(xlabel='a', ylabel='b') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to be clear, this doesn't try to somehow pull something out of |
||
plt.show() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,31 @@ | |
plt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^') | ||
plt.show() | ||
|
||
############################################################################### | ||
# .. _plotting-with-keywords: | ||
# | ||
# Plotting with keyword strings | ||
# ============================= | ||
# | ||
# There are some instances where you have data in a format that lets you | ||
# access particular variables with strings. For example, with | ||
# :class:`numpy.recarray` or :class:`pandas.DataFrame`. | ||
# | ||
# Matplotlib allows you provide such an object with | ||
# the ``data`` keyword argument. If provided, then you may generate plots with | ||
# the strings corresponding to these variables. | ||
|
||
data = dict([('a', np.arange(50)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Down here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops - this is how you know I should probably stop coding for the day ;-) |
||
('c', np.random.randint(0, 50, 50)), | ||
('d', np.random.randn(50))]) | ||
data['b'] = data['a'] + 10 * np.random.randn(50) | ||
data['d'] = np.abs(data['d']) * 100 | ||
|
||
plt.plot('a', 'b', color='c', data=data) | ||
plt.xlabel('a') | ||
plt.ylabel('b') | ||
plt.show() | ||
|
||
############################################################################### | ||
# .. _controlling-line-properties: | ||
# | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why make this change? Links no longer change colour on hover.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reason for this was to make the inline links show up within sphinx-gallery pages (they weren't showing up before). I didn't realize this was going to mess up the other links as well. A better way for me to have done this would be to add a new rule instead:
want me to add this commit to the toolkits PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fixed in the toolkit PR, works fine now and should be merged soon! Good find
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would that require a
:hover
rule as well?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep there's a new hover in there too