From: Gordon Williams [mailto:g_will@cyberus.ca]
I guess that answers the first question
Oliver wrote:
Actually I have a patch to wxPyPlot that adds bars. However
it is a hack:
you can't name the bars (AFAICT) and the x axis still has labels....
Bars can be labelled using the legend.
Not easy because wxPyPlot code uses type checking when asked to render
legend: requires polymarker or polyline for legend. Plus would need to
position etc. Did this differently, see below.
You can turn off the
x-axis using SetXSpec = None.Regards,
Gordon Williams
Just want labels off, not axis. Actually, want ticks too, and labels to be
legend.
So this is what I ended up doing, and killed two birds with one stone:
- Factored out the tick generation stuff, ie PlotCanvas.Draw takes extra
parameters that specify function to call to get the ticks.
- Use a helper function to generate a list of bar plots with proper (0,0)
and ticks
So the demo now has an extra menu item, whose callback looks like this:
def OnPlotBars(self, event):
self.resetDefaults()
# create a bunch of bars with various sizes and fill styles
bars, tickGen = getPolyBars(
BarInfo((0,1), colour='green', size=4, legend='Green bar'),
BarInfo((1,3), colour='red', size=7, legend='Red bar',
fillStyle=wx.wxCROSSDIAG_HATCH),
BarInfo((2,1), colour='blue', legend='Blue bar',
fillStyle=wx.wxTRANSPARENT))
# create the graph
graph = PlotGraphics(bars,
"Graph Title", "Bar names", "Bar height")
# draw it, using the ticks labels received from getPolyBars
self.client.Draw(bars, xAxis=(0,3), yAxis = (0,4),
xTickGenerator=tickGen)
This allows you to overlay bar chart and other plots, but if you use the bar
ticks you loose the autoscale ticks, which might be annoying. Any ideas what
should ticks be when a line plot and bar chart are on same graph?
Side effect of this, indep of bar charting, is that you can specify your own
"list of ticks", which is something I've needed to do before, because the
auto calc wasn't giving me the values I really wanted to see.
I wish I could show a snapshot but the virus checker doesn't let me email
jpgs.
Oliver