|
the posted:I have both plots working now, but I'm having a problem where I can't do them at the same time. Oh goddamnit. I probably should have read the edit before I actually spent the time to re-write the code. I'm an idiot. I'm going to explain the answer anyway, since this is a common mistake people new to matplotlib run into. Here's the code, I've just commented out the lines that "the" had originally in. code:
Now, you do *not* have to use subplots to display multiple figures. However, I find that using the subplot space makes life about a million times easier. Yeah, you may not always need to make multiple plots. In fact, for me, I generally do not. However, one horror you'll run into is that the parameters for subplots end up being different for those in "figure space" for lack of a better term. For example, look at the limit commands. If I was just passing it to the figure, I'd use fig1.xlim(), but in subplot space, I use set_xlim. So basically, since I *sometimes* use subplots, I just always use it so that I always just have the syntax in my head and don't have to flip back and forth. It's a simple matter to tell matplotlib your subplot is the entire figure, that's what add_subplot(111) does. By the way, I want to take this time to reiterate that you shouldn't use pylab. I would have imported matplotlib.pyplot, and then called the plotting commands from that module. Even the people who make matplotlib say don't use pylab. http://matplotlib.sourceforge.net/faq/usage_faq.html EDIT: I also am so obsessive about comments, that you can see that I even comment other people's code. (In this case, poorly, I was just making notes in case it took time).
|
# ? Apr 13, 2012 18:16 |
|
|
# ? May 9, 2024 14:15 |
|
Using subplots in matplotlib literally changes your world and you will never go back to using what I was calling "figure space".
|
# ? Apr 13, 2012 18:19 |
|
So I wrote a python package, and I uploaded it to pypi. It installs fine via python setup.py install, but won't install via pip install [package_name]. What am I missing? The package is here: http://pypi.python.org/pypi/django-easydump
|
# ? Apr 13, 2012 20:35 |
|
how!! posted:So I wrote a python package, and I uploaded it to pypi. It installs fine via python setup.py install, but won't install via pip install [package_name]. What am I missing? The package is here: http://pypi.python.org/pypi/django-easydump What error are you getting when trying to install it?
|
# ? Apr 13, 2012 22:33 |
|
Suspicious Dish posted:What error are you getting when trying to install it? code:
|
# ? Apr 14, 2012 00:03 |
|
I'm trying to figure out how to scrape the "XXXXX HAVE YOU IN CIRCLES" number from a Google+ profile page. (My page, just because I'm curious to plot trends about number of people following me and how that relates to things like posting frequency, day of the week, etc) Before G+ redesigned this week, it was a simple matter of a regex (gasp, I know...parsing HTML with a regex). They've gone and hosed that up, and I can't quite figure out how to get that number reliably. If I search the source for "have you in circles" the text doesn't even appear, and if I search with the current actual number as shown on the web page, it shows up in a couple of places that I don't get how to parse out programmatically. It's embedded in what looks like some sort of JSON structure or something... This may better belong to the general questions thread or somewhere, but I guess I'll start here since I'm doing it in Python. Here's my profile: https://plus.google.com/117177689300294532641/posts Anyone have a clue how to do this?
|
# ? Apr 14, 2012 00:35 |
|
You never uploaded any package. Use python setup.py sdist upload. See the documentation about PyPI for more details.
|
# ? Apr 14, 2012 00:38 |
|
Thermopyle posted:I'm trying to figure out how to scrape the "XXXXX HAVE YOU IN CIRCLES" number from a Google+ profile page. (My page, just because I'm curious to plot trends about number of people following me and how that relates to things like posting frequency, day of the week, etc) The correct way to do it is to use the API google provides (for free I think). If it's being generated by a script there's obviously no way to get it from parsing the HTML.
|
# ? Apr 14, 2012 20:03 |
|
Acallapani posted:The correct way to do it is to use the API google provides (for free I think). If it's being generated by a script there's obviously no way to get it from parsing the HTML. There is no official Google+ Circles API. There is an unofficial one, though.
|
# ? Apr 14, 2012 20:04 |
|
Acallapani posted:The correct way to do it is to use the API google provides (for free I think). If it's being generated by a script there's obviously no way to get it from parsing the HTML. There isn't one that gets this information. Suspicious Dish posted:There is no official Google+ Circles API. There is an unofficial one, though. Nice. I didn't want to get in to this, so glad to see someone else did it.
|
# ? Apr 14, 2012 20:36 |
|
Spime Wrangler posted:Enthought's Traits + Chaco caught my eye recently because I've literally never done GUI work before and needed to get something off the ground quick. I have to say that while I'm still a bit confused on how to properly go about getting some of the traits magic to work, and while there's almost no guides on the internet, the stuff is growing on me. http://python.mirocommunity.org/video/1690/pycon-2010-introduction-to-tra And here's a short tutorial on traits/chaco integration: http://drliddle.com/index.php?option=com_content&view=article&id=14:quicktuttraits&catid=3:tutorials&Itemid=6
|
# ? Apr 15, 2012 17:28 |
|
I'm using Sax to parse an XML file, and I'd like the program to stop after it finds n entries. Is there a better way to do this than to raise an error? Ideally one that doesn't require Python to stop completely.code:
|
# ? Apr 15, 2012 21:12 |
|
I'm working on a simple script to keep track of the number of tasks someone has completed. For some reason, it gives me a syntax error on line 36. I cannot figure out why. Let me know if you see the problem: http://pastebin.com/JZgmY7iX Edit: Good gravy, it was simply a matter of closing some parenthesis. I spent like 45 minutes hunting for the problem =( Chimp_On_Stilts fucked around with this message at 02:06 on Apr 16, 2012 |
# ? Apr 16, 2012 01:54 |
|
Count your parentheses!
|
# ? Apr 16, 2012 02:06 |
|
Acallapani posted:I'm using Sax to parse an XML file, and I'd like the program to stop after it finds n entries. Is there a better way to do this than to raise an error? Ideally one that doesn't require Python to stop completely. code:
The Gripper fucked around with this message at 10:03 on Apr 16, 2012 |
# ? Apr 16, 2012 09:46 |
|
Suspicious Dish posted:You never uploaded any package. Use python setup.py sdist upload. See the documentation about PyPI for more details. Ah, thanks. The problem I'm having now is the README and VERSION files (in the same folder as the setup.py file) is not being included in the package. here is my setup.py file: https://github.com/priestc/django-easydump/blob/master/setup.py When I run setup.py straight from from the git repo, it works, but installing from the sdist package tels me the VERSION and/or README file is not found. Did I do the package_data dict right?
|
# ? Apr 16, 2012 17:56 |
|
I'm attempting to figure out how to load and store settings for my project. I have a settings.json file (reason for JSON is that the same file is also used in Node) and I want to create an importable "singleton" that stores a reference to each setting defined in this file. For example, I want to do something like this:code:
Is there any way to do this without resorting to memcache or pickle?
|
# ? Apr 16, 2012 23:20 |
|
create a settings.py with a global variable to store the parsed settings. The global should be an instance of a type with overridden __getattr__ to read them.code:
code:
|
# ? Apr 17, 2012 00:58 |
|
how!! posted:Ah, thanks. The problem I'm having now is the README and VERSION files (in the same folder as the setup.py file) is not being included in the package. here is my setup.py file: You're using setuptools. Don't do that. Also, the way distutils constructs the distribution package is by something called a MANIFEST file. You need to look into that.
|
# ? Apr 17, 2012 02:46 |
|
Hanpan posted:
What? So, first of all, don't use module global attributes code:
code:
code:
|
# ? Apr 17, 2012 02:52 |
|
Okay, I'm feeling extremely dumb at the moment and Google isn't exactly helping. How exactly, does the following for loop work? code:
|
# ? Apr 17, 2012 03:10 |
|
quaunaut posted:Okay, I'm feeling extremely dumb at the moment and Google isn't exactly helping. It doesn't. It would have to be code:
|
# ? Apr 17, 2012 03:17 |
|
Suspicious Dish posted:It doesn't. It would have to be Well, how would it work there, exactly? Is it simply a way of saying, "go through each key and value pair of the dictionary" until done, effectively being little more than "for i in thing"? Edit: Thanks, both of you <3 quaunaut fucked around with this message at 03:40 on Apr 17, 2012 |
# ? Apr 17, 2012 03:20 |
|
there's three separate features interacting, there. the first is that iterating over a dictionary yields its keys, in arbitrary order: code:
code:
code:
Additionally, with the definition of 'dict.iteritems', you can get a for loop that'll iterate over all the key-value pairs in a dictionary.
|
# ? Apr 17, 2012 03:26 |
|
Janin posted:the third is that for loops (and also variable assignment) will automatically unpack tuples: I just want to note that this sort of unpacking works for any iterable, not just tuples: code:
code:
code:
Janin posted:Additionally, with the definition of 'dict.iteritems', you can get a for loop that'll iterate over all the key-value pairs in a dictionary. dict.iteritems is simply an optimization for dict.items, similar to how xrange is an optimization for range: >>> range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> xrange(10) <xrange object> >>> D = dict(A=1, B=2) # shorthand for {'A': 1, 'B': 2} >>> D.items() [('A', 1), ('B', 2)] >>> D.iteritems() <dictionary-itemiterator object> >>> next(_) # '_' is a special variable for the last result in the Python REPL ('A', 1)
|
# ? Apr 17, 2012 04:31 |
|
Suspicious Dish posted:I just want to note that this sort of unpacking works for any iterable, not just tuples:
|
# ? Apr 17, 2012 04:54 |
|
Janin posted:This is possible, but ewwww, please don't do it! It violates the semantics of the types and will make anyone who reads the code hate you. Well, yeah, I wouldn't ever do that, except in cases where the length of the generated sequence is explicitly specified, like islice. Rather than miss the point I'm trying to make completely by using something like that, I'd rather write something that shows the semantics I'm talking about, and attempt to make it blatantly obvious that this was just for demonstration purposes. ... I think I failed on that last part, there.
|
# ? Apr 17, 2012 05:45 |
|
BigRedDot posted:I used to work at Enthought, so sure, I've used Traits quite a bit in the past. And I contributed some parts of Chaco. I think they've both changed somewhat in the four or five years since I've used them extensively, but I might be able to answer some questions. Maybe you've seen this, but here is a tutorial session from pycon a few years ago: Thanks! I actually found the second one not long after I posted that, and I've got prototypes working of the basic traits + interactive chaco stuff I'll need. Once I got the hang of the basics with that and picking apart the draggable polygon example its gone very smoothly. I'm watching the video now, its been helpful so far.
|
# ? Apr 17, 2012 16:29 |
|
What is the best module/library for scientific data visualization? I have python 3.2 if it matters.
|
# ? Apr 17, 2012 20:24 |
|
Might be a stupid follow-up but are you looking for plotting libraries or data manipulation type libraries? Or neither and I will leave this to an expert.
|
# ? Apr 17, 2012 20:27 |
|
vikingstrike posted:Might be a stupid follow-up but are you looking for plotting libraries or data manipulation type libraries? Or neither and I will leave this to an expert. I have numpy and scipy installed. Now looking for plotting library. Basically I am trying to replicate Matlab with Python...
|
# ? Apr 17, 2012 20:48 |
|
Tovarisch posted:I have numpy and scipy installed. Now looking for plotting library. Basically I am trying to replicate Matlab with Python... You want matplotlib.
|
# ? Apr 17, 2012 21:06 |
|
Tovarisch posted:I have numpy and scipy installed. Now looking for plotting library. Basically I am trying to replicate Matlab with Python... edit: gotta start refreshing this page before applying, matplotlab is indeed your answer
|
# ? Apr 17, 2012 21:37 |
|
Thanks, took a while to find matplotlib for 3.2 (no link on official page) but finally installed it and examples work fine. Anyone has experience with iPython? I am trying to find an alternative to default python shell on windows, again to build something similar to matlab.
|
# ? Apr 17, 2012 21:42 |
|
I really enjoy iPython and at times find myself using it over the bash shell to get work done. (I can think in Python easier than bash on the fly.) I would recommend checking out the docs because there are some pretty cool features that you can use within it.
|
# ? Apr 17, 2012 21:50 |
|
I do not like IPython. It made me run in circles for a while trying to figure out why my code was broken, until I realized that it was IPython that broke my code, and my code was fine. I use bpython when I need a somewhat fancy interpreter. It doesn't work on Python 3, or Windows, though.
|
# ? Apr 17, 2012 21:53 |
|
Suspicious Dish posted:I do not like IPython. It made me run in circles for a while trying to figure out why my code was broken, until I realized that it was IPython that broke my code, and my code was fine. Out of curiosity now, what was iPython doing? I usually just use it for one off things, but I'll move to something else if it's broken.
|
# ? Apr 17, 2012 22:03 |
|
vikingstrike posted:Out of curiosity now, what was iPython doing? I usually just use it for one off things, but I'll move to something else if it's broken. I don't know, and I didn't investigate why it failed on IPython, just that it did, and I didn't care at that point as I had already lost several hours to it. It was failing with a weird exception when I added a __getattr__ to my class. Removing it made it work fine in IPython. Both versions worked fine under Python.
|
# ? Apr 17, 2012 22:07 |
|
ipython for me is a necessity. It's the first think I install in any virtualenv, and I've never once had a problem with it. Debugging code you input is as easy as %debug.
|
# ? Apr 17, 2012 23:16 |
|
|
# ? May 9, 2024 14:15 |
|
What was the main motivation for all the changes in Python 3.x? I had problems installing matplotlib for 3.2, now having problems with ipython since it wants setuptools, which in turn are not available for 3.2. Half of the examples from the book I have don't work with 3.2 and require changes... I mean there should be some strong reasons for such dramatic changes, especially if the language is well established and already has a lot of supporters.
|
# ? Apr 17, 2012 23:33 |