working on pyplot

This commit is contained in:
Thomas Breloff 2015-09-13 22:20:15 -04:00
parent 8d5412a38f
commit 36effc6dc4
2 changed files with 19 additions and 50 deletions

0
docs/pyplot_examples.md Normal file
View File

View File

@ -100,12 +100,9 @@ function plot(pkg::PyPlotPackage; kw...)
end end
# TODO: # TODO:
# - 2-axis # fillto # might have to use barHack/histogramHack??
# - bar # heatmap
# - hist # subplot
# - fillto/area
# - heatmap
# - subplot
# reg # true or false, add a regression line for each line # reg # true or false, add a regression line for each line
# pos # (Int,Int), move the enclosing window to this position # pos # (Int,Int), move the enclosing window to this position
# windowtitle # string or symbol, set the title of the enclosing windowtitle # windowtitle # string or symbol, set the title of the enclosing windowtitle
@ -122,7 +119,9 @@ function plot!(::PyPlotPackage, plt::Plot; kw...)
# we have different args depending on plot type # we have different args depending on plot type
if lt in (:hist, :sticks, :bar) if lt in (:hist, :sticks, :bar)
extraargs[:bottom] = d[:fillto] # NOTE: this is unsupported because it does the wrong thing... it shifts the whole axis
# extraargs[:bottom] = d[:fillto]
if lt == :hist if lt == :hist
extraargs[:bins] = d[:nbins] extraargs[:bins] = d[:nbins]
else else
@ -140,50 +139,20 @@ function plot!(::PyPlotPackage, plt::Plot; kw...)
end end
# if lt == :hist # set these for all types
# extraargs[:bins] = d[:nbins] extraargs[:figure] = plt.o
# elseif lt == :sticks extraargs[:color] = getPyPlotColor(d[:color])
# extraargs[:width] = 0.01 extraargs[:linewidth] = d[:width]
# extraargs[:bottom] = d[:fillto] extraargs[:label] = d[:label]
# elseif lt == :bar
# extraargs[:width] = 0.9
# extraargs[:bottom] = d[:fillto]
# end
# namespace = d[:axis] == :right ? plt.o[:axes]()[:twiny]() : PyPlot # do the plot
# plotfunc = plot if lt == :hist
# if lt == :hist plotfunc(d[:y]; extraargs...)
# plotfunc = hist else
# extraargs[:bins] = d[:nbins] plotfunc(d[:x], d[:y]; extraargs...)
# elseif lt in (:sticks, :bar) end
# plotfunc = bar
# extraargs[:width] = (lt == :sticks ? 0.01 : 0.9)
# end
# >>> p.plot([1,2],[2,1])
# [<matplotlib.lines.Line2D object at 0x107a04a50>]
# >>> a2 = f.axes[0].twinx()
# >>> a2.plot([1,2],[1,2])
# [<matplotlib.lines.Line2D object at 0x107a04f50>]
# >>> f.show()
# PyPlot.plot
dump(plotfunc)
plotfunc(d[:x], d[:y];
figure = plt.o,
color = getPyPlotColor(d[:color]),
linewidth = d[:width],
# linestyle = getPyPlotLineStyle(lt, d[:linestyle]),
# marker = getPyPlotMarker(d[:marker]),
# markersize = d[:markersize],
# markerfacecolor = getPyPlotColor(d[:markercolor]),
# drawstyle = getPyPlotDrawStyle(lt),
label = d[:label],
extraargs...
)
# add a legend?
if plt.initargs[:legend] if plt.initargs[:legend]
PyPlot.legend() PyPlot.legend()
end end
@ -200,7 +169,7 @@ end
function savepng(::PyPlotPackage, plt::PlottingObject, fn::String, args...) function savepng(::PyPlotPackage, plt::PlottingObject, fn::String, args...)
f = open(fn) f = open(fn)
writemime(f, MIME"image/png") writemime(f, "image/png", plt.o)
close(f) close(f)
end end