Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a5d42bf

Browse files
committed
fixed subplot bug
svn path=/trunk/matplotlib/; revision=173
1 parent e578cc3 commit a5d42bf

5 files changed

Lines changed: 49 additions & 23 deletions

File tree

MANIFEST

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ INTERACTIVE
88
KNOWN_BUGS
99
LICENSE
1010
LICENSE_PAINT
11+
MANIFEST
1112
MANIFEST.in
1213
Makefile
1314
README
@@ -424,19 +425,14 @@ src/_tkagg.cpp
424425
src/ft2font.c
425426
src/ft2font.h
426427
ttfquery/__init__.py
427-
ttfquery/__init__.pyc
428428
ttfquery/_scriptregistry.py
429-
ttfquery/_scriptregistry.pyc
430429
ttfquery/describe.py
431-
ttfquery/describe.pyc
432430
ttfquery/family_query.py
433431
ttfquery/findsystem.py
434-
ttfquery/findsystem.pyc
435432
ttfquery/font_family_groups.py
436433
ttfquery/glyph.py
437434
ttfquery/glyphquery.py
438435
ttfquery/guessdescription.py
439436
ttfquery/license.txt
440437
ttfquery/metadata_query.py
441438
ttfquery/ttffiles.py
442-
ttfquery/ttffiles.pyc

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# Copyright (C) 2003 <[email protected]>
33
# $Header$
44
# $Log$
5+
# Revision 1.24 2004/03/08 14:56:44 jdh2358
6+
# fixed subplot bug
7+
#
58
# Revision 1.23 2004/02/27 14:47:46 jdh2358
69
# added matplotlibrc and tk win32 compile fixes
710
#
@@ -132,7 +135,7 @@ htmldocs:
132135
cd htdocs;\
133136
${PYTHON} process_docs.py;\
134137
${PYTHON} convert.py;\
135-
tar cfz site.tar.gz *.html screenshots tut examples gd API_CHANGES;\
138+
tar cfz site.tar.gz *.html screenshots tut examples gd .matplotlibrc NUMARRAY_ISSUES API_CHANGES;\
136139
cd ..;\
137140
rm matplotlib/backends/*.so;\
138141

examples/simple_plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
figure(1)
44
t = arange(0.0, 1.0, 0.01)
55
s = sin(2*2*pi*t)
6-
plot(t, s)
6+
plot(t, s, linewidth=1.0)
77

88
xlabel('time (s)')
99
ylabel('voltage (mV)')

setup.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@
55

66
# build the freetype2 interface - this is required for mathtext
77
# Requires freetype2, and libz
8-
BUILD_FT2FONT = 0
8+
BUILD_FT2FONT = 1
99

1010
# Build the fonttools and TTFQuery packages, required by the Paint,
1111
# Agg and GD backends.
12-
BUILD_FONTTOOLS = 0
12+
BUILD_FONTTOOLS = 1
1313

1414
# Build the antigrain geometry toolkit. Agg makes heavy use of
1515
# templates, so it probably requires a fairly recent compiler to build
1616
# it. It makes very nice antialiased output and also supports alpha
1717
# blending
18-
BUILD_AGG = 0
18+
BUILD_AGG = 1
1919

2020
# The builds below are alpha. They use an image backend (eg GD or
2121
# Agg) to render to the GTK canvas. The idea is to could use a single
2222
# high quality image renderer to render to all the GUI windows
2323

2424
# build GTK GUI with Agg renderer ; requires pygtk src distros installed
25-
BUILD_GTKAGG = 0
25+
BUILD_GTKAGG = 1
2626

2727
# build GTK GUI with GD renderer ; requires pygtk and GD src distros installed
2828
BUILD_GTKGD = 0
2929

3030
# build TK GUI with Agg renderer ; requires Tkinter Python extension
3131
# and Tk includes
32-
BUILD_TKAGG = 0
32+
BUILD_TKAGG = 1
3333

3434
## You shouldn't need to customize below this point
3535

@@ -91,7 +91,7 @@
9191

9292

9393
setup(name="matplotlib",
94-
version= '0.51',
94+
version= '0.52a',
9595
description = "Matlab style python plotting package",
9696
author = "John D. Hunter",
9797
author_email="[email protected]",

src/_backend_agg.cpp

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,18 @@ double
4747
_points_to_pixels(RendererAggObject* renderer, double pt) {
4848
// convert a value in points to pixels depending on renderer dpi and
4949
// scrren pixels per inch
50+
return (pt*PIXELS_PER_INCH/72.0*renderer->dpi/72.0);
51+
52+
}
53+
54+
double
55+
_points_to_pixels_snapto(RendererAggObject* renderer, double pt) {
56+
// convert a value in points to pixels depending on renderer dpi and
57+
// scrren pixels per inch
58+
// snap return pixels to grid
5059
return (int)(pt*PIXELS_PER_INCH/72.0*renderer->dpi/72.0)+0.5;
5160

61+
5262
}
5363

5464

@@ -618,7 +628,7 @@ RendererAgg_draw_lines(RendererAggObject *renderer, PyObject* args) {
618628
PyObject *dashSeq = NULL;
619629
if (useDashes) {
620630
//TODO: use offset
621-
offset = _points_to_pixels(renderer, _seqitem_as_double(dashes, 0));
631+
offset = _points_to_pixels_snapto(renderer, _seqitem_as_double(dashes, 0));
622632
//note, you must decref this later if useDashes
623633
dashSeq = PySequence_GetItem(dashes, 1);
624634
};
@@ -629,14 +639,31 @@ RendererAgg_draw_lines(RendererAggObject *renderer, PyObject* args) {
629639

630640
double thisX, thisY;
631641
unsigned winHeight = renderer->rbase->height();
632-
thisX = (int)(_seqitem_as_double(x, 0))+0.5;
633-
thisY = (int)(winHeight - _seqitem_as_double(y, 0))+0.5;
634-
path.move_to(thisX, thisY);
635-
for (int i=1; i<Nx; ++i) {
636-
thisX = (int)(_seqitem_as_double(x, i))+0.5;
637-
thisY = (int)(winHeight - _seqitem_as_double(y, i)) + 0.5;
638-
path.line_to(thisX, thisY);
642+
643+
if (Nx==2) {
644+
// this is a little hack - len(2) lines are probably grid and
645+
// ticks so I'm going to snap to pixel
646+
thisX = (int)(_seqitem_as_double(x, 0))+0.5;
647+
thisY = (int)(winHeight - _seqitem_as_double(y, 0))+0.5;
648+
path.move_to(thisX, thisY);
649+
for (int i=1; i<Nx; ++i) {
650+
thisX = (int)(_seqitem_as_double(x, i))+0.5;
651+
thisY = (int)(winHeight - _seqitem_as_double(y, i)) + 0.5;
652+
path.line_to(thisX, thisY);
653+
}
639654
}
655+
else {
656+
thisX = _seqitem_as_double(x, 0);
657+
thisY = (winHeight - _seqitem_as_double(y, 0));
658+
path.move_to(thisX, thisY);
659+
for (int i=1; i<Nx; ++i) {
660+
thisX = (_seqitem_as_double(x, i));
661+
thisY = (winHeight - _seqitem_as_double(y, i)) ;
662+
path.line_to(thisX, thisY);
663+
}
664+
}
665+
666+
640667

641668

642669

@@ -671,8 +698,8 @@ RendererAgg_draw_lines(RendererAggObject *renderer, PyObject* args) {
671698
agg::conv_stroke<dash_t> stroke(dash);
672699
double on, off;
673700
for (int i=0; i<N/2; i+=2) {
674-
on = _points_to_pixels(renderer, _seqitem_as_double(dashSeq, 2*i));
675-
off = _points_to_pixels(renderer, _seqitem_as_double(dashSeq, 2*i+1));
701+
on = _points_to_pixels_snapto(renderer, _seqitem_as_double(dashSeq, 2*i));
702+
off = _points_to_pixels_snapto(renderer, _seqitem_as_double(dashSeq, 2*i+1));
676703
dash.add_dash(on, off);
677704
}
678705
stroke.line_cap(cap);

0 commit comments

Comments
 (0)