Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url:sourceforge': 0.03; 'from:addr:yahoo.co.uk': 0.04; 'skip:p 60': 0.07; 'wednesday,': 0.07; 'lawrence': 0.09; 'matplotlib': 0.09; 'pyplot': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:plot': 0.09; 'suggest': 0.14; 'expert,': 0.16; 'price,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'red,': 0.16; 'slight': 0.16; 'supplied': 0.16; 'why,': 0.16; 'wrote:': 0.18; 'skip:p 40': 0.19; '>>>': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'url:moin': 0.24; '2.0': 0.26; 'post': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply- To:1': 0.27; 'label': 0.30; "i'm": 0.30; 'went': 0.31; 'code': 0.31; 'reply.': 0.31; 'url:wiki': 0.31; '4.0': 0.31; 'fine,': 0.31; 'anyone': 0.31; 'this.': 0.32; 'figure': 0.32; 'url:python': 0.33; 'skip:# 10': 0.33; 'equal': 0.35; 'but': 0.35; 'there': 0.35; 'described': 0.36; 'url:listinfo': 0.36; 'thanks': 0.36; "i'll": 0.36; 'url:org': 0.36; 'list': 0.37; 'list.': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'aside': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'mailing': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'users': 0.40; 'how': 0.40; 'read': 0.60; 'most': 0.60; 'tell': 0.60; 'more': 0.64; 'different': 0.65; 'here': 0.66; 'price': 0.69; 'links,': 0.74; '$40': 0.84; 'glance': 0.84; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Markers on a matplotlib plot Date: Thu, 17 Oct 2013 08:06:03 +0100 References: <05dfa5c6-0516-403a-8970-f944084ac4ed@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-78-147-19-253.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 134 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381993807 news.xs4all.nl 15910 [2001:888:2000:d::a6]:48997 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56940 On 17/10/2013 02:31, Brandon La Porte wrote: > On Wednesday, 16 October 2013 18:31:09 UTC-4, Mark Lawrence wrote: >> On 16/10/2013 22:34, Brandon La Porte wrote: >> >>> I have the following code to make a plot of 4 different supply curves (economics). >> >>> >> >>> >> >>> from matplotlib import pyplot as plt >> >>> >> >>> price = range(0,51) >> >>> q1 = [x/2.0 for x in price] >> >>> q2 = [x/4.0 for x in price] >> >>> q3 = [x/5.0 for x in price] >> >>> q4 = [x/10.0 for x in price] >> >>> >> >>> markers_on = [20, 40] >> >>> >> >>> plt.plot(q1,price,'b',q2,price,'g',q3,price,'r', q4, price, 'y' ) >> >>> plt.title('Supply Curve') >> >>> plt.xlabel('Quantity Supplied (Thousands per month') >> >>> plt.ylabel('Price ($)') >> >>> #plt.legend(('Kd = %d'%kd, 'Kd = %d'%kd2, 'Kd = %d'% kd3, 'Step'), loc=4) >> >>> plt.legend(('p = 2Qs', 'p = 4Qs', 'p = 5Qs', 'p = 10Qs'), loc=4) >> >>> >> >>> plt.grid() >> >>> plt.show() >> >>> >> >>> I would like to place markers on the 4 curves when the price is equal to $20 label it A, and when the price is equal to $40 and label it B. Does anyone know how I can accomplish this. >> >>> >> >> >> >> If this matplotlib.pyplot.text described here >> >> http://matplotlib.org/api/pyplot_api.html isn't any good I suggest you >> >> ask on the dedicated matplotlib users mailing list see >> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> >> >> -- >> >> Roses are red, >> >> Violets are blue, >> >> Most poems rhyme, >> >> But this one doesn't. >> >> >> >> Mark Lawrence > > Hi Mark > > Thanks for the quick reply. I went through the documentation briefly and made some changes. > > from matplotlib import pyplot as plt > > q1 = 2.0 > q2 = 4.0 > q3 = 5.0 > q4 = 10.0 > > p1 = 20 > p2 = 40 > price = range(0,51) > qlist1 = [x/q1 for x in price] > qlist2 = [x/q2 for x in price] > qlist3 = [x/q3 for x in price] > qlist4 = [x/q4 for x in price] > > > plt.plot(qlist1,price,'b',qlist2,price,'g',qlist3,price,'r', qlist4, price, 'y' ) > plt.plot(p1/q1,p1,'ko', p1/q2, p1, 'ko', p1/q3,p1, 'ko', p1/q4, p1, 'ko') > plt.plot(p2/q1,p2,'ks', p2/q2, p2, 'ks', p2/q3,p2, 'ks', p2/q4, p2, 'ks') > > plt.title('Supply Curve') > plt.xlabel('Quantity Supplied (Thousands per month)') > plt.ylabel('Price ($)') > plt.legend(('p = 2Qs', 'p = 4Qs', 'p = 5Qs', 'p = 10Qs'), loc=4) > > plt.grid() > plt.show() > > > I'm sure there is a better or more "Pythonic" way to do this, and I still need to figure out how to label the individual points. Again thanks for the links, and I'll update this post when I figure it out. > > Thanks > Brandon > Fine, if you need more help I'll try but I'm no matplotlib expert, your best bet is still its user mailing list. Slight aside would you please read and action this link https://wiki.python.org/moin/GoogleGroupsPython, a quick glance above will tell you why, thanks :) -- Roses are red, Violets are blue, Most poems rhyme, But this one doesn't. Mark Lawrence