Hi, On Mon, Aug 18, 2008 at 2:25 PM, Darren Dale <[EMAIL PROTECTED]> wrote: > Could you post a *simple* script that reproduces the problem? And in the > meantime, to get a figure that looks better for your publication, can you > save your figure as an svg, import it into inkscape, tweak the bad placement, > and then save a pdf?
Thanks for the inkscape suggestion - I usually just use eps and pdf which I find harder to edit. Below is the function I use to create the plot. Actually I thought it happened with all legends, but I think I have just been focussing on these plots for too long, because when I check now it only seems to happen when I plot with this function. plot_stacked(arange(1,6),arange(1,6)) should reproduce the problem. Perhaps it is something to do with setting the labels to '' to delete the duplicate copies I don't want? Thanks, Robin def plot_stacked(*vals, **kwargs): fig = figure() sub = fig.add_subplot(111) ticks = kwargs.setdefault('ticks',[]) labels = kwargs.setdefault('labels',False) numstacks = len(vals) vallength = set([len(val) for val in vals]) if len(vallength) > 1: raise ValueError,'All input values should have the same length' vallength = vallength.pop() ind = 0.25 + arange(numstacks) width = 0.5 bottom = zeros(numstacks) colorvals = arange(vallength) * (1.0/(vallength-1)) orderlabels = ['First Order','Second Order','Third Order','Fourth Order'] if not labels: labels = orderlabels[:vallength-1] + ['Higher Order'] for i in range(vallength): ivals = [val[i] for val in vals] sub.bar(ind, ivals, width, bottom=bottom, color=str(colorvals[i]),label=labels[i]) bottom += ivals sub.set_xlim(0,numstacks+1.5) sub.set_xticks(ind+width/2) sub.set_xticklabels(ticks) # remove duplicate labels tmplabels = [] for rect in sub.patches: if rect.get_label() in tmplabels: rect.set_label('') else: tmplabels.append(rect.get_label()) sub.legend() fig.show() > > Darren > > > On Monday 18 August 2008 08:47:16 am Robin wrote: >> Hi, >> >> I was wondering if anyone was able to help with this problem of >> incorrect legend alignment. >> >> I am not sure if the original mail did not get through, perhaps >> because of the attachent, so this time I have put the example here: >> http://acrids.robince.net/robince/bad_legend.pdf >> >> Publication is now imminent and I have a horible feeling I am going to >> have to do all the plots again in Matlab unless we can resolve this >> problem - it currently looks very unprofessional. >> >> I would appreciate any pointers on where to look to try to resolve this. >> >> Thanks >> >> Robin >> >> On Thu, Jul 10, 2008 at 11:58 PM, Robin <[EMAIL PROTECTED]> wrote: >> > Hi, >> > >> > I have a problem with legends where the vertical spacing is sometimes >> > a bit funny (lines don't seem to be evenly spaced). >> > >> > I am now preparing some figures for publication and this is the last >> > niggle I'd really like to resolve. >> > >> > Is there anything I could do to fix this? >> > >> > A small example is attached (I cropped it to just the legend to reduce >> > file size). >> > >> > I am setting the label on the bars I am plotting and then just calling >> > ax.legend() >> > >> > At the risk of putting two queries in one email the only other problem >> > I have regularly is that small figures resize themselves when the >> > mouse rolls over them. I am using TkAgg backend on OS X but I think it >> > happens on other platforms as well. On mouse over the window jiggles >> > and resizes slightly. When I am saving figures I have to be careful to >> > call savefig from the command line without touching the window with >> > the mouse to ensure they save as the correct size. Just wondered if it >> > was a known issue... >> > >> > Apart from these minor things though matplotlib has been performing >> > great! >> > >> > Thanks, >> > >> > Robin >> >> ------------------------------------------------------------------------- >> This SF.Net email is sponsored by the Moblin Your Move Developer's >> challenge Build the coolest Linux based applications with Moblin SDK & win >> great prizes Grand prize is a trip for two to an Open Source event anywhere >> in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users