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

Implement geom_line with size mapping #161

Closed
jankatins opened this issue Jan 8, 2014 · 4 comments
Closed

Implement geom_line with size mapping #161

jankatins opened this issue Jan 8, 2014 · 4 comments
Labels

Comments

@jankatins
Copy link
Contributor

See this matplotlib bug for the details:

matplotlib/matplotlib#2658 (comment)

@jankatins
Copy link
Contributor Author

Here we have some code which does the deed:
from http://nbviewer.ipython.org/github/brianckeegan/Bechdel/blob/master/Bechdel_test.ipynb cell 37

# Changing line widths from: http://stackoverflow.com/questions/19862011/matplotlib-change-linewidth-on-line-segments-using-list
coords = sorted(dict(avg_bechdel).items(),key=lambda x:x[0])
lines = [(start, end) for start, end in zip(coords[:-1], coords[1:])]
lines = LineCollection(lines, linewidths=dict(num_movies).values())
# Plot the figure
fig, ax = plt.subplots()
ax.add_collection(lines)
plt.autoscale()
plt.xlim((1912,2020))
plt.xlabel('Time',fontsize=18)
plt.ylabel('Avg. Bechdel score',fontsize=18)

@has2k1
Copy link

has2k1 commented Apr 10, 2014

Good find, I'll try to add it to #266.

@jankatins
Copy link
Contributor Author

There is also the possibility to use "fill_between". We would need to compute the "betweens", but that shouldn't be hard ([line[x]-size[x],line[x]+size[x] for x in xmapping])

See second example here:
http://www.randalolson.com/2014/06/28/how-to-make-beautiful-data-visualizations-in-python-with-matplotlib/

@has2k1
Copy link

has2k1 commented Jul 24, 2014

When I played around with the first method (line collections), it could become very slow with increased points. On the other hand I have used "fill_between" to create a bar plot way faster than matplotlib does it.

A head on benchmark between the two is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants