annotate scripts/plot/appearance/legend.m @ 24534:194eb4bd202b

maint: Update punctuation for GPL v3 license text. * COPYING, Makefile.am, README, bootstrap, bootstrap.conf, OctJavaQry.java, changelog.tmpl, check-subst-vars.in.sh, find-defun-files.sh, find-files-with-tests.sh, get-source-mtime.sh, mk-hg-id.sh, mk-octave-config-h.sh, mk-opts.pl, stl_algo.h-fixed, subst-config-vals.in.sh, subst-cross-config-vals.in.sh, subst-default-vals.in.sh, subst-script-vals.in.sh, configure.ac, Doxyfile.in, arith.txi, audio.txi, basics.txi, bugs.txi, config-images.sh, container.txi, cp-idx.txi, data.txi, debug.txi, diagperm.txi, diffeq.txi, add_to_aspell_dict, mk_undocumented_list, spellcheck, errors.txi, eval.txi, expr.txi, external.txi, fn-idx.txi, func.txi, genpropdoc.m, geometry.txi, geometryimages.m, grammar.txi, gui.txi, image.txi, images.awk, install.txi, interp.txi, interpimages.m, intro.txi, io.txi, linalg.txi, macros.texi, matrix.txi, mk-doc-cache.pl, mkcontrib.awk, mkoctfile.1, munge-texi.pl, nonlin.txi, numbers.txi, obsolete.txi, octave-cli.1, octave-config.1, octave.1, octave.css, octave.texi, oop.txi, op-idx.txi, optim.txi, package.txi, plot.txi, plotimages.m, poly.txi, preface.txi, quad.txi, set.txi, signal.txi, sparse.txi, sparseimages.m, splineimages.m, stats.txi, stmt.txi, strings.txi, system.txi, testfun.txi, var.txi, vectorize.txi, array.texi, bugs.texi, cp-idx.texi, dae.texi, diffeq.texi, error.texi, factor.texi, fn-idx.texi, gpl.texi, install.texi, intro.texi, liboctave.texi, matvec.texi, nleqn.texi, nlfunc.texi, ode.texi, optim.texi, preface.texi, quad.texi, range.texi, refcard-a4.tex, refcard-legal.tex, refcard-letter.tex, refcard.tex, HACKING.md, octave.appdata.xml.in, Backend.cc, Backend.h, BaseControl.cc, BaseControl.h, ButtonControl.cc, ButtonControl.h, ButtonGroup.cc, ButtonGroup.h, Canvas.cc, Canvas.h, CheckBoxControl.cc, CheckBoxControl.h, Container.cc, Container.h, ContextMenu.cc, ContextMenu.h, EditControl.cc, EditControl.h, Figure.cc, Figure.h, FigureWindow.cc, FigureWindow.h, GLCanvas.cc, GLCanvas.h, GenericEventNotify.h, KeyMap.cc, KeyMap.h, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Logger.h, Menu.cc, Menu.h, MenuContainer.h, MouseModeActionGroup.cc, MouseModeActionGroup.h, Object.cc, Object.h, ObjectFactory.cc, ObjectFactory.h, ObjectProxy.cc, ObjectProxy.h, Panel.cc, Panel.h, PopupMenuControl.cc, PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h, PushTool.cc, PushTool.h, QtHandlesUtils.cc, QtHandlesUtils.h, RadioButtonControl.cc, RadioButtonControl.h, SliderControl.cc, SliderControl.h, TextControl.cc, TextControl.h, TextEdit.cc, TextEdit.h, ToggleButtonControl.cc, ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc, ToolBar.h, ToolBarButton.cc, ToolBarButton.h, __init_qt__.cc, __init_qt__.h, annotation-dialog.cc, annotation-dialog.h, gl-select.cc, gl-select.h, liboctgui-build-info.h, liboctgui-build-info.in.cc, mk-default-qt-settings.in.sh, QTerminal.cc, QTerminal.h, BlockArray.cpp, BlockArray.h, Character.h, CharacterColor.h, Emulation.cpp, Emulation.h, Filter.cpp, Filter.h, History.cpp, History.h, KeyboardTranslator.cpp, KeyboardTranslator.h, QUnixTerminalImpl.cpp, QUnixTerminalImpl.h, Screen.cpp, Screen.h, ScreenWindow.cpp, ScreenWindow.h, SelfListener.cpp, SelfListener.h, TerminalCharacterDecoder.cpp, TerminalCharacterDecoder.h, TerminalModel.cpp, TerminalModel.h, TerminalView.cpp, TerminalView.h, Vt102Emulation.cpp, Vt102Emulation.h, kpty.cpp, kpty.h, kpty_p.h, QTerminalColors.cpp, QTerminalColors.h, QWinTerminalImpl.cpp, QWinTerminalImpl.h, main.cpp, color-picker.cc, color-picker.h, dialog.cc, dialog.h, documentation-dock-widget.cc, documentation-dock-widget.h, external-editor-interface.cc, external-editor-interface.h, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc, find-files-dialog.h, find-files-model.cc, find-files-model.h, history-dock-widget.cc, history-dock-widget.h, file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc, find-dialog.h, marker.cc, marker.h, octave-qscintilla.cc, octave-qscintilla.h, octave-txt-lexer.cc, octave-txt-lexer.h, main-window.cc, main-window.h, octave-cmd.cc, octave-cmd.h, octave-dock-widget.cc, octave-dock-widget.h, octave-gui.cc, octave-gui.h, octave-qt-link.cc, octave-qt-link.h, octave-settings.h, texinfo-parser.cc, texinfo-parser.h, webinfo.cc, webinfo.h, resource-manager.cc, resource-manager.h, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc, shortcut-manager.h, terminal-dock-widget.cc, terminal-dock-widget.h, thread-manager.cc, thread-manager.h, variable-editor-model.cc, variable-editor-model.h, variable-editor.cc, variable-editor.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.cc, workspace-model.h, workspace-view.cc, workspace-view.h, build-env.h, build-env.in.cc, builtins.h, Cell.cc, Cell.h, __contourc__.cc, __dsearchn__.cc, __ichol__.cc, __ilu__.cc, __lin_interpn__.cc, __luinc__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, base-text-renderer.h, besselj.cc, betainc.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, cdisplay.c, cdisplay.h, cellfun.cc, coct-hdf5-types.c, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc, default-defs.in.h, defaults.cc, defaults.h, defun-dld.h, defun-int.h, defun.cc, defun.h, det.cc, dirfns.cc, dirfns.h, display.cc, display.h, dlmread.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc, ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.cc, errwarn.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, file-io.h, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gammainc.cc, gcd.cc, genprops.awk, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics-handle.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc, graphics.in.h, gripes.cc, gripes.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc, help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, inv.cc, kron.cc, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-hdf5.cc, ls-hdf5.h, ls-mat-ascii.cc, ls-mat-ascii.h, ls-mat4.cc, ls-mat4.h, ls-mat5.cc, ls-mat5.h, ls-oct-binary.cc, ls-oct-binary.h, ls-oct-text.cc, ls-oct-text.h, ls-utils.cc, ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex.cc, mex.h, mexproto.h, mgorth.cc, mk-errno-list.sh, mk-mxarray-h.in.sh, mxarray.in.h, nproc.cc, oct-errno.h, oct-errno.in.cc, oct-fstrm.cc, oct-fstrm.h, oct-handle.h, oct-hdf5-types.cc, oct-hdf5-types.h, oct-hdf5.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h, oct-map.cc, oct-map.h, oct-obj.h, oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.in.yy, oct.h, octave-default-image.h, octave-link.cc, octave-link.h, ordschur.cc, pager.cc, pager.h, pinv.cc, pr-output.cc, pr-output.h, procstream.cc, procstream.h, psi.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc, sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, toplev.h, tril.cc, tsearch.cc, txt-eng.cc, txt-eng.h, typecast.cc, url-handle-manager.cc, url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, workspace-element.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h, zfstream.cc, zfstream.h, deprecated-config.h, __delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, __osmesa_print__.cc, __voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc, colamd.cc, config-module.awk, config-module.sh, convhulln.cc, dmperm.cc, fftw.cc, gzip.cc, oct-qhull.h, qr.cc, symbfact.cc, symrcm.cc, liboctinterp-build-info.h, liboctinterp-build-info.in.cc, mk-build-env-features.sh, mk-builtins.pl, mk-doc.pl, mk-pkg-add.sh, mk-version-h.in.sh, ov-base-diag.cc, ov-base-diag.h, ov-base-int.cc, ov-base-int.h, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base-scalar.h, ov-base-sparse.cc, ov-base-sparse.h, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool-sparse.h, ov-bool.cc, ov-bool.h, ov-builtin.cc, ov-builtin.h, ov-cell.cc, ov-cell.h, ov-ch-mat.cc, ov-ch-mat.h, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-colon.cc, ov-colon.h, ov-complex.cc, ov-complex.h, ov-cs-list.cc, ov-cs-list.h, ov-cx-diag.cc, ov-cx-diag.h, ov-cx-mat.cc, ov-cx-mat.h, ov-cx-sparse.cc, ov-cx-sparse.h, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn-inline.cc, ov-fcn-inline.h, ov-fcn.cc, ov-fcn.h, ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h, ov-flt-cx-diag.cc, ov-flt-cx-diag.h, ov-flt-cx-mat.cc, ov-flt-cx-mat.h, ov-flt-re-diag.cc, ov-flt-re-diag.h, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-int-traits.h, ov-int16.cc, ov-int16.h, ov-int32.cc, ov-int32.h, ov-int64.cc, ov-int64.h, ov-int8.cc, ov-int8.h, ov-intx.h, ov-java.cc, ov-java.h, ov-lazy-idx.cc, ov-lazy-idx.h, ov-mex-fcn.cc, ov-mex-fcn.h, ov-null-mat.cc, ov-null-mat.h, ov-oncleanup.cc, ov-oncleanup.h, ov-perm.cc, ov-perm.h, ov-range.cc, ov-range.h, ov-re-diag.cc, ov-re-diag.h, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.cc, ov-scalar.h, ov-str-mat.cc, ov-str-mat.h, ov-struct.cc, ov-struct.h, ov-typeinfo.cc, ov-typeinfo.h, ov-uint16.cc, ov-uint16.h, ov-uint32.cc, ov-uint32.h, ov-uint64.cc, ov-uint64.h, ov-uint8.cc, ov-uint8.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, ovl.cc, ovl.h, octave.cc, octave.h, op-kw-docs, mk-ops.sh, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cdm-cm.cc, op-cdm-cs.cc, op-cdm-dm.cc, op-cdm-m.cc, op-cdm-s.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cdm.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-dm.cc, op-cm-m.cc, op-cm-pm.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc, op-dm-cdm.cc, op-dm-cm.cc, op-dm-cs.cc, op-dm-dm.cc, op-dm-m.cc, op-dm-s.cc, op-dm-scm.cc, op-dm-sm.cc, op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcdm-fcm.cc, op-fcdm-fcs.cc, op-fcdm-fdm.cc, op-fcdm-fm.cc, op-fcdm-fs.cc, op-fcm-fcdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fdm.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcm-pm.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fcdm.cc, op-fdm-fcm.cc, op-fdm-fcs.cc, op-fdm-fdm.cc, op-fdm-fm.cc, op-fdm-fs.cc, op-fm-fcdm.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fdm.cc, op-fm-fm.cc, op-fm-fs.cc, op-fm-pm.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc, op-int.h, op-m-cdm.cc, op-m-cm.cc, op-m-cs.cc, op-m-dm.cc, op-m-m.cc, op-m-pm.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-pm-cm.cc, op-pm-fcm.cc, op-pm-fm.cc, op-pm-m.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h, options-usage.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, jit-ir.cc, jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, jit-util.cc, jit-util.h, lex.h, lex.ll, oct-lvalue.cc, oct-lvalue.h, oct-parse.in.yy, octave.gperf, parse.h, profiler.cc, profiler.h, pt-all.h, pt-arg-list.cc, pt-arg-list.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-funcall.cc, pt-funcall.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jit.cc, pt-jit.h, pt-jump.cc, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-walk.cc, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Array-jit.cc, Array-tc.cc, version.cc, version.in.h, Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-fC.cc, Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc, Array-util.cc, Array-util.h, Array-voidp.cc, Array.cc, Array.h, CColVector.cc, CColVector.h, CDiagMatrix.cc, CDiagMatrix.h, CMatrix.cc, CMatrix.h, CNDArray.cc, CNDArray.h, CRowVector.cc, CRowVector.h, CSparse.cc, CSparse.h, DiagArray2.cc, DiagArray2.h, MArray-C.cc, MArray-d.cc, MArray-f.cc, MArray-fC.cc, MArray-i.cc, MArray-s.cc, MArray.cc, MArray.h, MDiagArray2.cc, MDiagArray2.h, MSparse-C.cc, MSparse-d.cc, MSparse.cc, MSparse.h, Matrix.h, MatrixType.cc, MatrixType.h, PermMatrix.cc, PermMatrix.h, Range.cc, Range.h, Sparse-C.cc, Sparse-b.cc, Sparse-d.cc, Sparse.cc, Sparse.h, boolMatrix.cc, boolMatrix.h, boolNDArray.cc, boolNDArray.h, boolSparse.cc, boolSparse.h, chMatrix.cc, chMatrix.h, chNDArray.cc, chNDArray.h, dColVector.cc, dColVector.h, dDiagMatrix.cc, dDiagMatrix.h, dMatrix.cc, dMatrix.h, dNDArray.cc, dNDArray.h, dRowVector.cc, dRowVector.h, dSparse.cc, dSparse.h, dim-vector.cc, dim-vector.h, fCColVector.cc, fCColVector.h, fCDiagMatrix.cc, fCDiagMatrix.h, fCMatrix.cc, fCMatrix.h, fCNDArray.cc, fCNDArray.h, fCRowVector.cc, fCRowVector.h, fColVector.cc, fColVector.h, fDiagMatrix.cc, fDiagMatrix.h, fMatrix.cc, fMatrix.h, fNDArray.cc, fNDArray.h, fRowVector.cc, fRowVector.h, idx-vector.cc, idx-vector.h, int16NDArray.cc, int16NDArray.h, int32NDArray.cc, int32NDArray.h, int64NDArray.cc, int64NDArray.h, int8NDArray.cc, int8NDArray.h, intNDArray.cc, intNDArray.h, uint16NDArray.cc, uint16NDArray.h, uint32NDArray.cc, uint32NDArray.h, uint64NDArray.cc, uint64NDArray.h, uint8NDArray.cc, uint8NDArray.h, cconv2.f, cdotc3.f, cmatm3.f, csconv2.f, dconv2.f, ddot3.f, dmatm3.f, sconv2.f, sdot3.f, smatm3.f, zconv2.f, zdconv2.f, zdotc3.f, zmatm3.f, crsf2csf.f, zrsf2csf.f, mk-f77-def.in.sh, liboctave-build-info.h, liboctave-build-info.in.cc, CollocWt.cc, CollocWt.h, DAE.h, DAEFunc.h, DAERT.h, DAERTFunc.h, DASPK-opts.in, DASPK.cc, DASPK.h, DASRT-opts.in, DASRT.cc, DASRT.h, DASSL-opts.in, DASSL.cc, DASSL.h, DET.h, EIG.cc, EIG.h, LSODE-opts.in, LSODE.cc, LSODE.h, ODE.h, ODEFunc.h, ODES.cc, ODES.h, ODESFunc.h, Quad-opts.in, Quad.cc, Quad.h, aepbalance.cc, aepbalance.h, base-dae.h, base-de.h, base-min.h, bsxfun-decl.h, bsxfun-defs.cc, bsxfun.h, chol.cc, chol.h, eigs-base.cc, eigs-base.h, fEIG.cc, fEIG.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-amos-proto.h, lo-arpack-proto.h, lo-blas-proto.h, lo-fftpack-proto.h, lo-lapack-proto.h, lo-mappers.cc, lo-mappers.h, lo-qrupdate-proto.h, lo-ranlib-proto.h, lo-slatec-proto.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc, randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-dmsolve.cc, sparse-dmsolve.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, Sparse-diag-op-defs.h, Sparse-op-decls.h, Sparse-op-defs.h, Sparse-perm-op-defs.h, config-ops.sh, mk-ops.awk, mx-base.h, mx-defs.h, mx-ext.h, mx-inlines.cc, mx-op-decl.h, mx-op-defs.h, mx-ops, smx-ops, vx-ops, child-list.cc, child-list.h, cmach-info.c, cmach-info.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-passwd.cc, oct-passwd.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.h, base-list.h, blaswrap.c, byte-swap.h, caseless-str.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, cquit.c, data-conv.cc, data-conv.h, f2c-main.c, f77-fcn.c, f77-fcn.h, file-info.cc, file-info.h, functor.h, glob-match.cc, glob-match.h, kpse.cc, kpse.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-array-gripes.cc, lo-array-gripes.h, lo-cutils.c, lo-cutils.h, lo-error.c, lo-error.h, lo-hash.cc, lo-hash.h, lo-ieee.cc, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-traits.h, lo-utils.cc, lo-utils.h, oct-base64.cc, oct-base64.h, oct-binmap.h, oct-cmplx.h, oct-glob.cc, oct-glob.h, oct-inttypes-fwd.h, oct-inttypes.cc, oct-inttypes.h, oct-locbuf.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-rl-edit.c, oct-rl-edit.h, oct-rl-hist.c, oct-rl-hist.h, oct-shlib.cc, oct-shlib.h, oct-sort.cc, oct-sort.h, oct-sparse.cc, oct-sparse.h, oct-string.cc, oct-string.h, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, quit.h, singleton-cleanup.cc, singleton-cleanup.h, sparse-sort.cc, sparse-sort.h, sparse-util.cc, sparse-util.h, str-vec.cc, str-vec.h, sun-utils.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h, areadlink-wrapper.c, areadlink-wrapper.h, async-system-wrapper.c, async-system-wrapper.h, base64-wrappers.c, base64-wrappers.h, canonicalize-file-name-wrapper.c, canonicalize-file-name-wrapper.h, dirent-wrappers.c, dirent-wrappers.h, fcntl-wrappers.c, fcntl-wrappers.h, filepos-wrappers.c, filepos-wrappers.h, fpucw-wrappers.c, fpucw-wrappers.h, gen-tempname-wrapper.c, gen-tempname-wrapper.h, getopt-wrapper.c, getopt-wrapper.h, glob-wrappers.c, glob-wrappers.h, hash-wrappers.c, hash-wrappers.h, localcharset-wrapper.c, localcharset-wrapper.h, math-wrappers.c, math-wrappers.h, mkostemp-wrapper.c, mkostemp-wrapper.h, nanosleep-wrapper.c, nanosleep-wrapper.h, nproc-wrapper.c, nproc-wrapper.h, octave-popen2.c, octave-popen2.h, putenv-wrapper.c, putenv-wrapper.h, set-program-name-wrapper.c, set-program-name-wrapper.h, signal-wrappers.c, signal-wrappers.h, stat-wrappers.c, stat-wrappers.h, strdup-wrapper.c, strdup-wrapper.h, strftime-wrapper.c, strftime-wrapper.h, strmode-wrapper.c, strmode-wrapper.h, strptime-wrapper.c, strptime-wrapper.h, time-wrappers.c, time-wrappers.h, tmpfile-wrapper.c, tmpfile-wrapper.h, uname-wrapper.c, uname-wrapper.h, uniconv-wrappers.c, uniconv-wrappers.h, unistd-wrappers.c, unistd-wrappers.h, unsetenv-wrapper.c, unsetenv-wrapper.h, vasprintf-wrapper.c, vasprintf-wrapper.h, wait-for-input.c, wait-for-input.h, wait-wrappers.c, wait-wrappers.h, acinclude.m4, ax_blas.m4, ax_lapack.m4, ax_openmp.m4, ax_pthread.m4, octave_blas_f77_func.m4, pkg.m4, oct-conf-post.in.h, run-octave.in, Map.m, ascii.m, binary.m, cd.m, close.m, delete.m, dir.m, disp.m, ftp.m, loadobj.m, mget.m, mkdir.m, mput.m, rename.m, rmdir.m, saveobj.m, __get_properties__.m, audioplayer.m, disp.m, get.m, isplaying.m, pause.m, play.m, playblocking.m, resume.m, set.m, stop.m, subsasgn.m, subsref.m, __get_properties__.m, audiorecorder.m, disp.m, get.m, getaudiodata.m, getplayer.m, isrecording.m, pause.m, play.m, record.m, recordblocking.m, resume.m, set.m, stop.m, subsasgn.m, subsref.m, lin2mu.m, mu2lin.m, record.m, sound.m, soundsc.m, bitmax.m, chop.m, comma.m, isstr.m, mahalanobis.m, md5sum.m, octave_config_info.m, onenormest.m, paren.m, semicolon.m, sleep.m, usleep.m, wavread.m, wavwrite.m, acosd.m, acot.m, acotd.m, acoth.m, acsc.m, acscd.m, acsch.m, asec.m, asecd.m, asech.m, asind.m, atan2d.m, atand.m, cosd.m, cot.m, cotd.m, coth.m, csc.m, cscd.m, csch.m, sec.m, secd.m, sech.m, sind.m, tand.m, accumarray.m, accumdim.m, bincoeff.m, bitcmp.m, bitget.m, bitset.m, blkdiag.m, cart2pol.m, cart2sph.m, cell2mat.m, celldisp.m, circshift.m, common_size.m, cplxpair.m, cumtrapz.m, curl.m, dblquad.m, deal.m, deg2rad.m, del2.m, divergence.m, flip.m, flipdim.m, fliplr.m, flipud.m, gradient.m, idivide.m, int2str.m, integral.m, integral2.m, integral3.m, interp1.m, interp2.m, interp3.m, interpft.m, interpn.m, isequal.m, isequaln.m, logspace.m, nextpow2.m, num2str.m, pol2cart.m, polyarea.m, postpad.m, prepad.m, __splinen__.m, quad2d.m, quadgk.m, quadl.m, quadv.m, rad2deg.m, randi.m, rat.m, repelem.m, repmat.m, rot90.m, rotdim.m, shift.m, shiftdim.m, sortrows.m, sph2cart.m, structfun.m, subsindex.m, trapz.m, triplequad.m, xor.m, convhull.m, delaunay.m, delaunayn.m, dsearch.m, dsearchn.m, griddata.m, griddata3.m, griddatan.m, inpolygon.m, rectint.m, tsearchn.m, voronoi.m, voronoin.m, dialog.m, errordlg.m, getappdata.m, guidata.m, guihandles.m, helpdlg.m, inputdlg.m, isappdata.m, listdlg.m, msgbox.m, __file_filter__.m, __fltk_file_filter__.m, __get_funcname__.m, __is_function__.m, __uigetdir_fltk__.m, __uigetfile_fltk__.m, __uiobject_split_args__.m, __uiputfile_fltk__.m, questdlg.m, rmappdata.m, setappdata.m, uibuttongroup.m, uicontextmenu.m, uicontrol.m, uigetdir.m, uigetfile.m, uimenu.m, uipanel.m, uipushtool.m, uiputfile.m, uiresume.m, uitoggletool.m, uitoolbar.m, uiwait.m, waitbar.m, waitforbuttonpress.m, warndlg.m, __gripe_missing_component__.m, __makeinfo__.m, __unimplemented__.m, ans.m, debug.m, doc.m, doc_cache_create.m, error_ids.m, get_first_help_sentence.m, help.m, lookfor.m, print_usage.m, __additional_help_message__.m, __strip_html_tags__.m, slash.m, type.m, warning_ids.m, which.m, autumn.m, bone.m, brighten.m, cmpermute.m, cmunique.m, colorcube.m, colormap.m, contrast.m, cool.m, copper.m, cubehelix.m, flag.m, frame2im.m, getframe.m, gray.m, gray2ind.m, hot.m, hsv.m, hsv2rgb.m, im2double.m, im2frame.m, image.m, imagesc.m, imfinfo.m, imformats.m, imread.m, imshow.m, imwrite.m, ind2gray.m, ind2rgb.m, iscolormap.m, jet.m, lines.m, ntsc2rgb.m, ocean.m, pink.m, prism.m, __imfinfo__.m, __imread__.m, __imwrite__.m, colorspace_conversion_input_check.m, colorspace_conversion_revert.m, imageIO.m, imwrite_filename.m, ind2x.m, rainbow.m, rgb2hsv.m, rgb2ind.m, rgb2ntsc.m, rgbplot.m, spinmap.m, spring.m, summer.m, viridis.m, white.m, winter.m, beep.m, csvread.m, csvwrite.m, dlmwrite.m, fileread.m, importdata.m, is_valid_file_id.m, strread.m, textread.m, javaArray.m, java_get.m, java_set.m, javaaddpath.m, javachk.m, javaclasspath.m, javamem.m, javarmpath.m, ClassHelper.java, Matrix.java, OctClassLoader.java, Octave.java, OctaveReference.java, usejava.m, bandwidth.m, commutation_matrix.m, cond.m, condeig.m, condest.m, cross.m, duplication_matrix.m, expm.m, gls.m, housh.m, isbanded.m, isdefinite.m, isdiag.m, ishermitian.m, issymmetric.m, istril.m, istriu.m, krylov.m, linsolve.m, logm.m, lscov.m, normest.m, normest1.m, null.m, ols.m, orth.m, planerot.m, qzhess.m, rank.m, rref.m, subspace.m, trace.m, vech.m, vecnorm.m, bug_report.m, bunzip2.m, cast.m, citation.m, compare_versions.m, computer.m, copyfile.m, delete.m, desktop.m, dir.m, dos.m, edit.m, fact.m, fieldnames.m, fileattrib.m, fileparts.m, fullfile.m, genvarname.m, getfield.m, grabcode.m, gunzip.m, info.m, inputParser.m, inputname.m, isdeployed.m, isdir.m, ismac.m, ispc.m, isunix.m, license.m, list_primes.m, loadobj.m, ls.m, ls_command.m, menu.m, methods.m, mex.m, mexext.m, mkdir.m, mkoctfile.m, movefile.m, namelengthmax.m, nargchk.m, narginchk.m, nargoutchk.m, news.m, nthargout.m, open.m, orderfields.m, pack.m, parseparams.m, perl.m, __publish_html_output__.m, __publish_latex_output__.m, __w2mpth__.m, display_info_file.m, publish.m, python.m, recycle.m, run.m, saveobj.m, setfield.m, substruct.m, swapbytes.m, symvar.m, tar.m, tempdir.m, tmpnam.m, unix.m, unpack.m, untar.m, unzip.m, validateattributes.m, ver.m, version.m, what.m, zip.m, mk-doc.pl, mk-pkg-add.sh, decic.m, ode15i.m, ode15s.m, ode23.m, ode45.m, odeget.m, odeplot.m, odeset.m, AbsRel_norm.m, check_default_input.m, integrate_adaptive.m, kahan.m, ode_event_handler.m, odedefaults.m, odemergeopts.m, runge_kutta_23.m, runge_kutta_45_dorpri.m, runge_kutta_interpolate.m, starting_stepsize.m, __all_opts__.m, fminbnd.m, fminsearch.m, fminunc.m, fsolve.m, fzero.m, glpk.m, humps.m, lsqnonneg.m, optimget.m, optimset.m, pqpnonneg.m, __fdjac__.m, qp.m, sqp.m, import.m, matlabroot.m, pathdef.m, getsavepath.m, savepath.m, pkg.m, build.m, configure_make.m, default_prefix.m, describe.m, dirempty.m, get_description.m, get_forge_download.m, get_forge_pkg.m, get_unsatisfied_deps.m, getarch.m, getarchdir.m, install.m, installed_packages.m, list_forge_packages.m, load_packages.m, load_packages_and_dependencies.m, rebuild.m, save_order.m, uninstall.m, unload_packages.m, __clabel__.m, __getlegenddata__.m, __rotate_around_axis__.m, annotation.m, axis.m, box.m, camlookat.m, camorbit.m, campos.m, camroll.m, camtarget.m, camup.m, camva.m, camzoom.m, caxis.m, clabel.m, daspect.m, datetick.m, diffuse.m, grid.m, gtext.m, hidden.m, legend.m, lighting.m, material.m, orient.m, pbaspect.m, __axis_label__.m, __axis_limits__.m, rticks.m, shading.m, specular.m, text.m, thetaticks.m, title.m, view.m, whitebg.m, xlabel.m, xlim.m, xticklabels.m, xticks.m, ylabel.m, ylim.m, yticklabels.m, yticks.m, zlabel.m, zlim.m, zticklabels.m, zticks.m, area.m, bar.m, barh.m, camlight.m, colorbar.m, comet.m, comet3.m, compass.m, contour.m, contour3.m, contourc.m, contourf.m, cylinder.m, ellipsoid.m, errorbar.m, ezcontour.m, ezcontourf.m, ezmesh.m, ezmeshc.m, ezplot.m, ezplot3.m, ezpolar.m, ezsurf.m, ezsurfc.m, feather.m, fill.m, fplot.m, hist.m, isocaps.m, isocolors.m, isonormals.m, isosurface.m, light.m, line.m, loglog.m, loglogerr.m, mesh.m, meshc.m, meshz.m, pareto.m, patch.m, pcolor.m, peaks.m, pie.m, pie3.m, plot.m, plot3.m, plotmatrix.m, plotyy.m, polar.m, __add_datasource__.m, __bar__.m, __calc_isovalue_from_data__.m, __contour__.m, __errplot__.m, __ezplot__.m, __interp_cube__.m, __line__.m, __marching_cube__.m, __patch__.m, __pie__.m, __plt__.m, __quiver__.m, __scatter__.m, __stem__.m, __unite_shared_vertices__.m, quiver.m, quiver3.m, rectangle.m, reducepatch.m, reducevolume.m, ribbon.m, rose.m, scatter.m, scatter3.m, semilogx.m, semilogxerr.m, semilogy.m, semilogyerr.m, shrinkfaces.m, slice.m, smooth3.m, sombrero.m, sphere.m, stairs.m, stem.m, stem3.m, stemleaf.m, surf.m, surface.m, surfc.m, surfl.m, surfnorm.m, tetramesh.m, trimesh.m, triplot.m, trisurf.m, waterfall.m, __actual_axis_position__.m, __default_plot_options__.m, __gnuplot_drawnow__.m, __next_line_color__.m, __next_line_style__.m, __opengl_info__.m, __plt_get_axis_arg__.m, __pltopt__.m, allchild.m, ancestor.m, axes.m, cla.m, clf.m, close.m, closereq.m, colstyle.m, copyobj.m, figure.m, findall.m, findfigs.m, findobj.m, gca.m, gcbf.m, gcbo.m, gcf.m, gco.m, ginput.m, gnuplot_binary.in.m, graphics_toolkit.m, groot.m, hdl2struct.m, hggroup.m, hgload.m, hgsave.m, hgtransform.m, hold.m, isaxes.m, isfigure.m, isgraphics.m, ishandle.m, ishold.m, isprop.m, linkaxes.m, linkprop.m, meshgrid.m, ndgrid.m, newplot.m, pan.m, print.m, printd.m, __add_default_menu__.m, __ghostscript__.m, __gnuplot_draw_axes__.m, __gnuplot_draw_figure__.m, __gnuplot_get_var__.m, __gnuplot_ginput__.m, __gnuplot_has_feature__.m, __gnuplot_has_terminal__.m, __gnuplot_open_stream__.m, __gnuplot_print__.m, __gnuplot_version__.m, __opengl_print__.m, __print_parse_opts__.m, __set_default_mouse_modes__.m, refresh.m, refreshdata.m, rotate.m, rotate3d.m, saveas.m, shg.m, struct2hdl.m, subplot.m, zoom.m, compan.m, conv.m, deconv.m, mkpp.m, mpoles.m, padecoef.m, pchip.m, poly.m, polyaffine.m, polyder.m, polyeig.m, polyfit.m, polygcd.m, polyint.m, polyout.m, polyreduce.m, polyval.m, polyvalm.m, ppder.m, ppint.m, ppjumps.m, ppval.m, residue.m, roots.m, spline.m, splinefit.m, unmkpp.m, addpref.m, getpref.m, ispref.m, prefdir.m, preferences.m, loadprefs.m, prefsfile.m, saveprefs.m, rmpref.m, setpref.m, style.css, profexplore.m, profexport.m, profile.m, profshow.m, intersect.m, ismember.m, powerset.m, validsetargs.m, setdiff.m, setxor.m, union.m, unique.m, arch_fit.m, arch_rnd.m, arch_test.m, arma_rnd.m, autoreg_matrix.m, bartlett.m, blackman.m, detrend.m, diffpara.m, durbinlevinson.m, fftconv.m, fftfilt.m, fftshift.m, filter2.m, fractdiff.m, freqz.m, freqz_plot.m, hamming.m, hanning.m, hurst.m, ifftshift.m, periodogram.m, rectangle_lw.m, rectangle_sw.m, triangle_lw.m, triangle_sw.m, sinc.m, sinetone.m, sinewave.m, spectral_adf.m, spectral_xdf.m, spencer.m, stft.m, synthesis.m, unwrap.m, yulewalker.m, bicg.m, bicgstab.m, cgs.m, colperm.m, eigs.m, etreeplot.m, gmres.m, gplot.m, ichol.m, ilu.m, nonzeros.m, pcg.m, pcr.m, __sprand__.m, qmr.m, spaugment.m, spconvert.m, spdiags.m, speye.m, spfun.m, spones.m, sprand.m, sprandn.m, sprandsym.m, spstats.m, spy.m, svds.m, treelayout.m, treeplot.m, bessel.m, beta.m, betaln.m, ellipke.m, expint.m, factor.m, factorial.m, isprime.m, lcm.m, legendre.m, nchoosek.m, nthroot.m, perms.m, pow2.m, primes.m, reallog.m, realpow.m, realsqrt.m, gallery.m, hadamard.m, hankel.m, hilb.m, invhilb.m, magic.m, pascal.m, rosser.m, toeplitz.m, vander.m, wilkinson.m, __finish__.m, center.m, cloglog.m, corr.m, corrcoef.m, cov.m, crosstab.m, histc.m, iqr.m, kendall.m, kurtosis.m, logit.m, mean.m, meansq.m, median.m, mode.m, moment.m, ppplot.m, prctile.m, probit.m, qqplot.m, quantile.m, range.m, ranks.m, run_count.m, runlength.m, skewness.m, spearman.m, statistics.m, std.m, var.m, zscore.m, betacdf.m, betainv.m, betapdf.m, betarnd.m, binocdf.m, binoinv.m, binopdf.m, binornd.m, cauchy_cdf.m, cauchy_inv.m, cauchy_pdf.m, cauchy_rnd.m, chi2cdf.m, chi2inv.m, chi2pdf.m, chi2rnd.m, discrete_cdf.m, discrete_inv.m, discrete_pdf.m, discrete_rnd.m, empirical_cdf.m, empirical_inv.m, empirical_pdf.m, empirical_rnd.m, expcdf.m, expinv.m, exppdf.m, exprnd.m, fcdf.m, finv.m, fpdf.m, frnd.m, gamcdf.m, gaminv.m, gampdf.m, gamrnd.m, geocdf.m, geoinv.m, geopdf.m, geornd.m, hygecdf.m, hygeinv.m, hygepdf.m, hygernd.m, kolmogorov_smirnov_cdf.m, laplace_cdf.m, laplace_inv.m, laplace_pdf.m, laplace_rnd.m, logistic_cdf.m, logistic_inv.m, logistic_pdf.m, logistic_rnd.m, logncdf.m, logninv.m, lognpdf.m, lognrnd.m, nbincdf.m, nbininv.m, nbinpdf.m, nbinrnd.m, normcdf.m, norminv.m, normpdf.m, normrnd.m, poisscdf.m, poissinv.m, poisspdf.m, poissrnd.m, stdnormal_cdf.m, stdnormal_inv.m, stdnormal_pdf.m, stdnormal_rnd.m, tcdf.m, tinv.m, tpdf.m, trnd.m, unidcdf.m, unidinv.m, unidpdf.m, unidrnd.m, unifcdf.m, unifinv.m, unifpdf.m, unifrnd.m, wblcdf.m, wblinv.m, wblpdf.m, wblrnd.m, wienrnd.m, logistic_regression.m, logistic_regression_derivatives.m, logistic_regression_likelihood.m, anova.m, bartlett_test.m, chisquare_test_homogeneity.m, chisquare_test_independence.m, cor_test.m, f_test_regression.m, hotelling_test.m, hotelling_test_2.m, kolmogorov_smirnov_test.m, kolmogorov_smirnov_test_2.m, kruskal_wallis_test.m, manova.m, mcnemar_test.m, prop_test_2.m, run_test.m, sign_test.m, t_test.m, t_test_2.m, t_test_regression.m, u_test.m, var_test.m, welch_test.m, wilcoxon_test.m, z_test.m, z_test_2.m, base2dec.m, bin2dec.m, blanks.m, cstrcat.m, deblank.m, dec2base.m, dec2bin.m, dec2hex.m, erase.m, findstr.m, hex2dec.m, index.m, isletter.m, isstring.m, isstrprop.m, mat2str.m, native2unicode.m, ostrsplit.m, regexptranslate.m, rindex.m, str2num.m, strcat.m, strchr.m, strjoin.m, strjust.m, strmatch.m, strsplit.m, strtok.m, strtrim.m, strtrunc.m, substr.m, unicode2native.m, untabify.m, validatestring.m, __have_feature__.m, __printf_assert__.m, __prog_output_assert__.m, __run_test_suite__.m, assert.m, demo.m, example.m, fail.m, compare_plot_demos.m, dump_demos.m, html_compare_plot_demos.m, rundemos.m, runtests.m, speed.m, test.m, addtodate.m, asctime.m, calendar.m, clock.m, ctime.m, date.m, datenum.m, datestr.m, datevec.m, eomday.m, etime.m, is_leap_year.m, now.m, weekday.m, display-available.c, display-available.h, main-cli.cc, main-gui.cc, main.in.cc, mkoctfile.in.cc, octave-build-info.h, octave-build-info.in.cc, octave-config.in.cc, shared-fcns.h, args.tst, bug-31371.tst, bug-35448.tst, bug-35881.tst, bug-36025.tst, bug-38236.tst, bug-38565.tst, bug-38576.tst, bug-38691.tst, bug-41723.tst, bug-44940.tst, bug-46330.tst, bug-46660.tst, bug-50014.tst, bug-50035.tst, bug-50716.tst, bug-51192.tst, bug-51532.tst, bug-51534.tst, bug-51599.tst, bug-52075.tst, class-concat.tst, classdef-multiple-inheritance.tst, classdef.tst, classes.tst, colormaps.tst, command.tst, complex.tst, ctor-vs-method.tst, deprecate-props.tst, diag-perm.tst, error.tst, eval-catch.tst, fcn-handle-derived-resolution.tst, fntests.m, for.tst, func.tst, global.tst, if.tst, index.tst, io.tst, jit.tst, leftdiv.tst, line-continue.tst, logical-index.tst, mk-bc-overloads-tst.sh, mk-conv-tst.sh, mk-sparse-tst.sh, nest.tst, null-assign.tst, parser.tst, prefer.tst, publish.tst, range.tst, recursion.tst, return.tst, show-failures.awk, single-index.tst, slice.tst, struct.tst, switch.tst, system.tst, transpose.tst, try.tst, unwind.tst, while.tst: Changed punctuation of GPL license text to match that suggested by FSF.
author Rik <rik@octave.org>
date Sat, 06 Jan 2018 07:57:19 -0800
parents 5865d2fef424
children ab2321d4ba03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
1 ## Copyright (C) 2010-2017 David Bateman
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
2 ##
6440
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6395
diff changeset
3 ## This file is part of Octave.
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6395
diff changeset
4 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24498
diff changeset
5 ## Octave is free software: you can redistribute it and/or modify it
6440
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6395
diff changeset
6 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24498
diff changeset
7 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22631
diff changeset
8 ## (at your option) any later version.
6440
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6395
diff changeset
9 ##
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6395
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6395
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22631
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22631
diff changeset
13 ## GNU General Public License for more details.
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
14 ##
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24498
diff changeset
17 ## <https://www.gnu.org/licenses/>.
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
18
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
20 ## @deftypefn {} {} legend ()
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
21 ## @deftypefnx {} {} legend (@var{str1}, @var{str2}, @dots{})
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
22 ## @deftypefnx {} {} legend (@var{charmat})
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
23 ## @deftypefnx {} {} legend (@{@var{cellstr}@})
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20781
diff changeset
24 ## @deftypefnx {} {} legend (@dots{}, "location", @var{pos})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20781
diff changeset
25 ## @deftypefnx {} {} legend (@dots{}, "orientation", @var{orient})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20781
diff changeset
26 ## @deftypefnx {} {} legend (@var{hax}, @dots{})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20781
diff changeset
27 ## @deftypefnx {} {} legend (@var{hobjs}, @dots{})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20781
diff changeset
28 ## @deftypefnx {} {} legend (@var{hax}, @var{hobjs}, @dots{})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20781
diff changeset
29 ## @deftypefnx {} {} legend ("@var{option}")
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
30 ## @deftypefnx {} {} legend (@dots{}, @{@var{cellstr}@}, @var{property}, @var{value}, @dots{})
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20781
diff changeset
31 ## @deftypefnx {} {[@var{hleg}, @var{hleg_obj}, @var{hplot}, @var{labels}] =} legend (@dots{})
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
32 ##
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17119
diff changeset
33 ## Display a legend for the current axes using the specified strings as labels.
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17119
diff changeset
34 ##
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17119
diff changeset
35 ## Legend entries may be specified as individual character string arguments,
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
36 ## a character array, or a cell array of character strings. When label names
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
37 ## might be confused with options to @code{legend}, the labels should be
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
38 ## protected by specifying them as a cell array of strings.
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
39 ##
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
40 ## If the first argument @var{hax} is an axes handle, then add a legend to this
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
41 ## axes, rather than the current axes returned by @code{gca}.
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17119
diff changeset
42 ##
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
43 ## Legend labels are associated with the axes' children; The first label is
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
44 ## assigned to the first object that was plotted in the axes, the second label
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
45 ## to the next object plotted, etc. To label specific data objects, without
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
46 ## labeling all objects, provide their graphic handles in the input
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
47 ## @var{hobjs}.
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
48 ##
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
49 ## The optional parameter @var{pos} specifies the location of the legend as
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
50 ## follows:
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
51 ##
6977
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
52 ## @multitable @columnfractions 0.06 0.14 0.80
17204
d87179b38bcf doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents: 17190
diff changeset
53 ## @headitem @tab pos @tab location of the legend
d87179b38bcf doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents: 17190
diff changeset
54 ## @item @tab north @tab center top
d87179b38bcf doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents: 17190
diff changeset
55 ## @item @tab south @tab center bottom
d87179b38bcf doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents: 17190
diff changeset
56 ## @item @tab east @tab right center
d87179b38bcf doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents: 17190
diff changeset
57 ## @item @tab west @tab left center
d87179b38bcf doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents: 17190
diff changeset
58 ## @item @tab northeast @tab right top (default)
d87179b38bcf doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents: 17190
diff changeset
59 ## @item @tab northwest @tab left top
d87179b38bcf doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents: 17190
diff changeset
60 ## @item @tab southeast @tab right bottom
d87179b38bcf doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents: 17190
diff changeset
61 ## @item @tab southwest @tab left bottom
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
62 ## @sp 1
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
63 ## @item @tab outside @tab can be appended to any location string @*
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
64 ## @item @tab @tab which will place the legend outside the axes
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
65 ## @end multitable
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
66 ##
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
67 ## The optional parameter @var{orient} determines if the legend elements are
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19880
diff changeset
68 ## placed vertically or horizontally. The allowed values are
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17204
diff changeset
69 ## @qcode{"vertical"} (default) or @qcode{"horizontal"}.
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
70 ##
10666
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
71 ## The following customizations are available using @var{option}:
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
72 ##
7148
735086cfd405 [project @ 2007-11-09 18:01:44 by jwe]
jwe
parents: 7054
diff changeset
73 ## @table @asis
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17204
diff changeset
74 ## @item @qcode{"show"}
10666
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
75 ## Show legend on the plot
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10666
diff changeset
76 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17204
diff changeset
77 ## @item @qcode{"hide"}
10666
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
78 ## Hide legend on the plot
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10666
diff changeset
79 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17204
diff changeset
80 ## @item @qcode{"toggle"}
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
81 ## Toggle between @qcode{"hide"} and @qcode{"show"}
12394
c2e1973d870b legend.m: "legend off" should delete the legend object.
Ben Abbott <bpabbott@mac.com>
parents: 12388
diff changeset
82 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17204
diff changeset
83 ## @item @qcode{"boxon"}
17532
492d609d2d75 legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents: 17530
diff changeset
84 ## Show a box around legend (default)
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10666
diff changeset
85 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17204
diff changeset
86 ## @item @qcode{"boxoff"}
10666
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
87 ## Hide the box around legend
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10666
diff changeset
88 ##
17532
492d609d2d75 legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents: 17530
diff changeset
89 ## @item @qcode{"right"}
492d609d2d75 legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents: 17530
diff changeset
90 ## Place label text to the right of the keys (default)
492d609d2d75 legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents: 17530
diff changeset
91 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17204
diff changeset
92 ## @item @qcode{"left"}
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
93 ## Place label text to the left of the keys
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10666
diff changeset
94 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17204
diff changeset
95 ## @item @qcode{"off"}
12394
c2e1973d870b legend.m: "legend off" should delete the legend object.
Ben Abbott <bpabbott@mac.com>
parents: 12388
diff changeset
96 ## Delete the legend object
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
97 ## @end table
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
98 ##
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
99 ## The @code{legend} function creates a graphics object which has various
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
100 ## properties that can be manipulated with @code{get}/@code{set}.
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
101 ## Alternatively, properties can be set directly when calling @code{legend} by
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
102 ## including @var{property}/@var{value} pairs. If using this calling form, the
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
103 ## labels must be specified as a cell array of strings.
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
104 ##
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
105 ## The optional output values are
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
106 ##
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
107 ## @table @var
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
108 ## @item hleg
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
109 ## The graphics handle of the legend object.
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
110 ##
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
111 ## @item hleg_obj
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
112 ## Graphics handles to the text, patch, and line objects which form the
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
113 ## legend.
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
114 ##
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
115 ## @item hplot
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
116 ## Graphics handles to the plot objects which were used in making the legend.
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
117 ##
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
118 ## @item labels
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
119 ## A cell array of strings of the labels in the legend.
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
120 ## @end table
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
121 ##
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
122 ## Implementation Note: The legend label text is either provided in the call to
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
123 ## @code{legend} or is taken from the @code{DisplayName} property of the
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
124 ## graphics objects. Only data objects, such as line, patch, and surface, have
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
125 ## this property whereas axes, figures, etc.@: do not so they are never present
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
126 ## in a legend. If no labels or @code{DisplayName} properties are available,
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
127 ## then the label text is simply @qcode{"data1"}, @qcode{"data2"}, @dots{},
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
128 ## @nospell{@qcode{"dataN"}}. No more than 20 data labels will be
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
129 ## automatically generated. To label more, call @code{legend} explicitly and
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
130 ## provide all labels.
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17119
diff changeset
131 ##
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
132 ## The legend @code{FontSize} property is initially set to 90% of the axes
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
133 ## @code{FontSize} to which it is attached. Use @code{set} to override this
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
134 ## if necessary.
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
135 ##
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
136 ## A legend is implemented as an additional axes object with the @code{tag}
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
137 ## property set to @qcode{"legend"}. Properties of the legend object may be
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
138 ## manipulated directly by using @code{set}.
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
139 ## @end deftypefn
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
140
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
141 function [hleg, hleg_obj, hplot, labels] = legend (varargin)
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
142
11246
c463aed850b0 allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents: 11200
diff changeset
143 if (nargin > 0
24423
1d52db450db4 Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents: 24403
diff changeset
144 && (! ishghandle (varargin{1})
11246
c463aed850b0 allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents: 11200
diff changeset
145 || (strcmp (get (varargin{1}, "type"), "axes")
c463aed850b0 allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents: 11200
diff changeset
146 && ! strcmp (get (varargin{1}, "tag"), "legend"))))
17065
991e8a386aa3 legend.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16973
diff changeset
147 [ca, varargin, nargin] = __plt_get_axis_arg__ ("legend", varargin{:});
991e8a386aa3 legend.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16973
diff changeset
148 if (isempty (ca))
991e8a386aa3 legend.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16973
diff changeset
149 ca = gca ();
991e8a386aa3 legend.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16973
diff changeset
150 endif
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
151 hfig = ancestor (ca, "figure");
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
152 else
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
153 hfig = get (0, "currentfigure");
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
154 if (isempty (hfig))
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
155 hfig = gcf ();
11246
c463aed850b0 allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents: 11200
diff changeset
156 endif
c463aed850b0 allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents: 11200
diff changeset
157 ca = gca ();
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
158 endif
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
159
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
160 ## Special handling for plotyy which has two axes objects
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
161 if (isprop (ca, "__plotyy_axes__"))
13216
434e227b100b Improvements to plotyy.
Ben Abbott <bpabbott@mac.com>
parents: 13141
diff changeset
162 plty = get (ca, "__plotyy_axes__");
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
163 ca = [ca, plty.'];
13216
434e227b100b Improvements to plotyy.
Ben Abbott <bpabbott@mac.com>
parents: 13141
diff changeset
164 ## Remove duplicates while preserving order
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
165 [~, n] = unique (ca, "first");
15440
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
166 ca = ca(sort (n));
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
167 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
168
24423
1d52db450db4 Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents: 24403
diff changeset
169 if (nargin > 0 && all (ishghandle (varargin{1})))
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
170 ## List of plot objects to label given as first argument
10662
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
171 kids = flipud (varargin{1}(:));
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
172 varargin(1) = [];
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
173 else
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
174 ## Find list of plot objects from axes "children"
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
175 kids = ca;
15440
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
176 kids(strcmp (get (ca, "tag"), "legend")) = [];
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
177 if (isscalar (kids))
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
178 kids = get (kids, "children")(:);
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
179 else
23257
61ec2557eece Fix order of legend labels with plotyy axes (bug #50497)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23253
diff changeset
180 kids = vertcat (flipud (get (kids, "children")){:});
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
181 endif
10662
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
182 endif
11246
c463aed850b0 allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents: 11200
diff changeset
183 nargs = numel (varargin);
10662
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
184 nkids = numel (kids);
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
185
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
186 ## Find any existing legend object associated with axes
18734
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
187 hlegend = [];
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
188 for hax = ca
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
189 try
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
190 hlegend = get (hax, "__legend_handle__");
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
191 if (! isempty (hlegend))
18734
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
192 break;
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
193 endif
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
194 end_try_catch
18734
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
195 endfor
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
196
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
197 orientation = "default";
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
198 location = "default";
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
199 show = "create";
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
200 textpos = "default";
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
201 box = "default";
18734
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
202 delete_leg = false;
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
203 find_leg_hdl = (nargs == 0); # possibly overridden
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
204 propvals = {};
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
205
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
206 ## Process old way of specifying location with a number rather than a string.
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
207 ## FIXME: When can this be deleted?
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
208 if (nargs > 0)
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
209 pos = varargin{nargs};
13279
984359717d71 Use common code idiom for checking whether a double value is an integer.
Rik <octave@nomad.inbox5.com>
parents: 13216
diff changeset
210 if (isnumeric (pos) && isscalar (pos) && pos == fix (pos))
6395
a8dd70bacc1e [project @ 2007-03-07 22:22:12 by jwe]
jwe
parents: 6272
diff changeset
211 if (pos >= -1 && pos <= 4)
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
212 location = [{"northeastoutside", "best", "northeast",
11003
b1cfff739af5 legend.m: Index location cellstr to obtain a string.
Ben Abbott <bpabbott@mac.com>
parents: 10999
diff changeset
213 "northwest", "southwest", "southeast"}] {pos + 2};
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
214 varargin(nargs) = [];
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20711
diff changeset
215 nargs -= 1;
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
216 else
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
217 error ("legend: invalid location specified");
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
218 endif
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
219 endif
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
220 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
221
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
222 ## Find "location" and "orientation" property/value pairs
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
223 while (nargs > 1)
6977
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
224 pos = varargin{nargs-1};
7054
1c5b2b5b58ba [project @ 2007-10-23 23:22:16 by jwe]
jwe
parents: 7017
diff changeset
225 str = varargin{nargs};
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
226 if (strcmpi (pos, "location") && ischar (str))
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
227 location = lower (str);
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
228 varargin(nargs-1:nargs) = [];
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
229 nargs -= 2;
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
230 elseif (strcmpi (pos, "orientation") && ischar (str))
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
231 orientation = lower (str);
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
232 varargin(nargs-1:nargs) = [];
10989
6ea65c5de87a Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10949
diff changeset
233 nargs -= 2;
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
234 else
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
235 break;
6977
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
236 endif
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
237 endwhile
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
238
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
239 ## Validate the orientation
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
240 switch (orientation)
15440
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
241 case {"vertical", "horizontal", "default"}
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
242 ## These are all accepted orientations.
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
243 otherwise
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
244 error ("legend: unrecognized legend orientation");
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
245 endswitch
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
246
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
247 ## Validate the location type
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
248 outside = false;
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
249 inout = strfind (location, "outside");
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
250 if (! isempty (inout))
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
251 outside = true;
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
252 location = location(1:inout-1);
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
253 else
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
254 outside = false;
6977
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
255 endif
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
256
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
257 switch (location)
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
258 case {"north", "south", "east", "west", "northeast", "northwest", ...
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
259 "southeast", "southwest", "default"}
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
260 case "best"
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
261 warning ("legend: 'best' not yet implemented for location specifier\n");
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
262 location = "northeast";
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
263 case "none"
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
264 ## FIXME: Should there be any more error checking on this?
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
265 otherwise
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
266 error ("legend: unrecognized legend location");
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
267 endswitch
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
268
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
269 ## Finish input processing based on number of inputs
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
270 if (nargs == 0)
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
271 ## No labels given, create a new legend or return existing one
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
272 if (isempty (hlegend))
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
273 show = "create";
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
274 textpos = "right";
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
275 find_leg_hdl = false;
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
276 endif
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
277
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
278 elseif (nargs == 1)
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
279 ## Either OPTION value, single string label, or cellstr of labels.
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
280 arg = varargin{1};
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
281 if (ischar (arg))
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
282 if (rows (arg) == 1)
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
283 str = lower (strtrim (arg));
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
284 switch (str)
15440
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
285 case "off"
18734
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
286 delete_leg = true;
15440
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
287 case "hide"
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
288 show = "off";
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20711
diff changeset
289 nargs -= 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
290 case "show"
15440
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
291 if (! isempty (hlegend))
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
292 show = "on";
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
293 else
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
294 show = "create";
17532
492d609d2d75 legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents: 17530
diff changeset
295 textpos = "right";
15440
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
296 endif
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20711
diff changeset
297 nargs -= 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
298 case "toggle"
15440
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
299 if (isempty (hlegend))
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
300 show = "create";
17532
492d609d2d75 legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents: 17530
diff changeset
301 textpos = "right";
15440
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
302 elseif (strcmp (get (hlegend, "visible"), "off"))
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
303 show = "on";
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
304 else
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
305 show = "off";
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
306 endif
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20711
diff changeset
307 nargs -= 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
308 case "boxon"
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
309 box = "on";
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20711
diff changeset
310 nargs -= 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
311 case "boxoff"
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
312 box = "off";
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20711
diff changeset
313 nargs -= 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
314 case "left"
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
315 textpos = "left";
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20711
diff changeset
316 nargs -= 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
317 case "right"
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
318 textpos = "right";
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20711
diff changeset
319 nargs -= 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
320 endswitch
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
321 else
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
322 ## Character matrix of labels
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
323 varargin = cellstr (arg);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
324 nargs = numel (varargin);
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
325 endif
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
326 elseif (iscellstr (arg))
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
327 ## Cell array of labels
8529
774b44619c5c Fix legend order for both horizontal and vertical string cell.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 8343
diff changeset
328 varargin = arg;
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
329 nargs = numel (varargin);
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
330 else
20711
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20408
diff changeset
331 error ("legend: single argument must be a string or cellstr");
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
332 endif
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
333
14589
fd6e50e2eee6 legend() should accept labels being specified as both cellstrs and char.
Ben Abbott <bpabbott@mac.com>
parents: 14585
diff changeset
334 elseif (nargs > 1 && iscellstr (varargin{1}))
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
335 ## Cell array of labels followed by property/value pairs
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
336 propvals = varargin(2:end);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
337 if (rem (numel (propvals), 2) != 0)
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
338 error ("legend: PROPERTY/VALUE arguments must occur in pairs");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
339 endif
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
340 varargin = {varargin{1}{:}};
14589
fd6e50e2eee6 legend() should accept labels being specified as both cellstrs and char.
Ben Abbott <bpabbott@mac.com>
parents: 14585
diff changeset
341 nargs = numel (varargin);
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
342 endif
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
343
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
344 have_labels = (nargs > 0);
18734
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
345 hobjects = [];
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
346 hplots = [];
18734
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
347 text_strings = {};
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
348
18734
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
349 if (delete_leg)
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
350 delete (hlegend);
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
351 hlegend = [];
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
352 elseif (find_leg_hdl)
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
353 ## Don't change anything about legend.
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
354 ## hleg output will be assigned hlegend value at end of function.
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
355 elseif (strcmp (show, "off"))
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
356 if (! isempty (hlegend))
21898
b5313b6cbe72 Simplify handling of 'box' property for legend axes objects.
Rik <rik@octave.org>
parents: 21758
diff changeset
357 set (hlegend, "visible", "off");
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
358 hlegend = [];
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
359 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
360 elseif (strcmp (show, "on"))
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
361 if (! isempty (hlegend))
21898
b5313b6cbe72 Simplify handling of 'box' property for legend axes objects.
Rik <rik@octave.org>
parents: 21758
diff changeset
362 set (hlegend, "visible", "on");
b5313b6cbe72 Simplify handling of 'box' property for legend axes objects.
Rik <rik@octave.org>
parents: 21758
diff changeset
363 ## NOTE: Matlab sets both "visible" and "box" to "on" for "show on"
b5313b6cbe72 Simplify handling of 'box' property for legend axes objects.
Rik <rik@octave.org>
parents: 21758
diff changeset
364 ## set (hlegend, "box", "on");
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
365 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
366 elseif (strcmp (box, "on"))
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
367 if (! isempty (hlegend))
21898
b5313b6cbe72 Simplify handling of 'box' property for legend axes objects.
Rik <rik@octave.org>
parents: 21758
diff changeset
368 set (hlegend, "box", "on");
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
369 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
370 elseif (strcmp (box, "off"))
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
371 if (! isempty (hlegend))
21898
b5313b6cbe72 Simplify handling of 'box' property for legend axes objects.
Rik <rik@octave.org>
parents: 21758
diff changeset
372 set (hlegend, "box", "off");
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
373 endif
18734
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
374 elseif (! have_labels && ! isempty (hlegend)
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
375 && ! (strcmp (location, "default")
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
376 && strcmp (orientation, "default")))
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
377 ## Changing location or orientation of existing legend
18734
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
378 if (strcmp (location, "default"))
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
379 set (hlegend, "orientation", orientation);
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
380 elseif (strcmp (orientation, "default"))
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
381 if (outside)
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
382 set (hlegend, "location", [location "outside"]);
12398
735e43b75e45 Allow the legend location and orientation to be set without modifying the legend keys (#32374)
David Bateman <dbateman@free.fr>
parents: 12396
diff changeset
383 else
18734
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
384 set (hlegend, "location", location);
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
385 endif
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
386 else
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
387 if (outside)
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
388 set (hlegend, "location", [location "outside"],
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
389 "orientation", orientation);
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
390 else
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
391 set (hlegend, "location", location,
adb948d7fae4 legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents: 18647
diff changeset
392 "orientation", orientation);
12398
735e43b75e45 Allow the legend location and orientation to be set without modifying the legend keys (#32374)
David Bateman <dbateman@free.fr>
parents: 12396
diff changeset
393 endif
735e43b75e45 Allow the legend location and orientation to be set without modifying the legend keys (#32374)
David Bateman <dbateman@free.fr>
parents: 12396
diff changeset
394 endif
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
395 else
24403
b9462090773a legend.m: Setting DisplayName to "" should delete legend (bug #52641).
Rik <rik@octave.org>
parents: 24399
diff changeset
396 ## Create or modify legend object
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
397
24403
b9462090773a legend.m: Setting DisplayName to "" should delete legend (bug #52641).
Rik <rik@octave.org>
parents: 24399
diff changeset
398 if (! isempty (hlegend))
b9462090773a legend.m: Setting DisplayName to "" should delete legend (bug #52641).
Rik <rik@octave.org>
parents: 24399
diff changeset
399 ## Disable callbacks while modifying an existing legend
24472
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
400 setappdata (hlegend, "nocallbacks", true);
24403
b9462090773a legend.m: Setting DisplayName to "" should delete legend (bug #52641).
Rik <rik@octave.org>
parents: 24399
diff changeset
401 endif
b9462090773a legend.m: Setting DisplayName to "" should delete legend (bug #52641).
Rik <rik@octave.org>
parents: 24399
diff changeset
402
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
403 if (have_labels)
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
404 ## Check for valid data that can be labeled.
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
405 have_data = false;
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
406 have_dname = false;
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
407 for hkid = kids.'
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
408 typ = get (hkid, "type");
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
409 if (any (strcmp (typ, {"line", "patch", "surface", "hggroup"})))
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
410 have_data = true;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
411 break;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
412 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
413 endfor
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
414
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
415 if (! have_data)
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
416 warning ("legend: plot data is empty; setting key labels has no effect");
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
417 endif
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
418 else
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
419 ## No labels. Search for DisplayName property.
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
420 have_dname = false;
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
421 n_dname = 0;
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
422 for hkid = kids.'
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
423 typ = get (hkid, "type");
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
424 if (any (strcmp (typ, {"line", "patch", "surface", "hggroup"})))
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
425 n_dname += 1; # count of objects which could be labeled
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
426 if (! isempty (get (hkid, "displayname")))
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
427 have_dname = true;
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
428 break;
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
429 endif
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
430 endif
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
431 endfor
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
432 have_data = n_dname > 0;
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
433 endif
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
434
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
435 if (have_labels || ! have_dname)
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
436 k = nkids;
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
437 if (! have_labels)
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
438 ## No labels or DisplayName. Create set of "dataX" labels.
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
439 if (n_dname > 20)
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
440 warning ("legend: labeling only first 20 data objects");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
441 n_dname = 20;
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
442 endif
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
443 nargs = n_dname;
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
444 varargin = arrayfun (@(x) sprintf ("data%d", x), [1:nargs]',
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
445 "uniformoutput", false);
16795
38c1a421f082 When no keys are specified and defaults are populated, set have_labels = true.
Ben Abbott <bpabbott@mac.com>
parents: 16728
diff changeset
446 have_labels = true;
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
447 endif
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
448 for i = 1 : nargs
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
449 label = varargin{i};
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
450 if (! ischar (label))
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
451 error ("legend: expecting label to be a string");
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
452 endif
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
453 ## Locate an object which can be labeled
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
454 while (k > 0)
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
455 typ = get (kids(k), "type");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
456 if (any (strcmp (typ, {"line","patch","surface","hggroup"})))
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
457 break;
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
458 endif
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
459 k--;
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
460 endwhile
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
461 if (k > 0)
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
462 set (kids(k), "displayname", label);
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
463 hplots(end+1) = kids(k);
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
464 text_strings(end+1) = label;
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
465 k--;
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
466 else
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
467 if (have_data)
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
468 warning ("legend: ignoring extra labels");
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
469 endif
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
470 break; # k = 0, no further handles to process
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
471 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
472 endfor
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
473
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
474 else
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
475 ## No labels specified but objects have DisplayName property set.
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
476 k = nkids;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
477 while (k > 0)
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
478 ## Locate object to label
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
479 while (k > 0)
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
480 typ = get (kids(k), "type");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
481 if (any (strcmp (typ, {"line","patch","surface","hggroup"})))
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
482 break;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
483 endif
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
484 k--;
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
485 endwhile
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
486 if (k > 0)
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
487 dname = get (kids(k), "displayname");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
488 if (! isempty (dname))
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
489 hplots(end+1) = kids(k);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
490 text_strings(end+1) = dname;
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
491 endif
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
492 k--;
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
493 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
494 endwhile
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
495 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
496
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
497 if (isempty (hplots))
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
498 ## Nothing to label
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
499 if (! isempty (hlegend))
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
500 delete (hlegend);
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
501 hlegend = [];
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
502 hobjects = [];
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
503 hplots = [];
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
504 text_strings = {};
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
505 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
506 else
14578
f579a94aacaa Preserve legend handle when changing properties (Bug # 36259).
Carnë Draug <carandraug+dev@gmail.com>
parents: 14552
diff changeset
507 ## Preserve the old legend if it exists
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
508 if (! isempty (hlegend))
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
509 if (strcmp (textpos, "default"))
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
510 textpos = get (hlegend, "textposition");
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
511 endif
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
512 if (strcmp (location, "default"))
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
513 location = get (hlegend, "location");
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
514 inout = strfind (location, "outside");
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
515 if (! isempty (inout))
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
516 outside = true;
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
517 location = location(1:inout-1);
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
518 else
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
519 outside = false;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
520 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
521 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
522 if (strcmp (orientation, "default"))
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
523 orientation = get (hlegend, "orientation");
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
524 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
525 box = get (hlegend, "box");
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
526 else
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
527 if (strcmp (textpos, "default"))
17532
492d609d2d75 legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents: 17530
diff changeset
528 textpos = "right";
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
529 endif
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
530 if (strcmp (location, "default"))
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
531 location = "northeast";
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
532 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
533 if (strcmp (orientation, "default"))
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
534 orientation = "vertical";
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
535 endif
14529
aabdc8f281f1 legend.m: Change default to boxon for Matlab compatibility (bug #36105).
Rik <octave@nomad.inbox5.com>
parents: 14375
diff changeset
536 box = "on";
6272
a1f3d3b7ee5c [project @ 2007-02-06 02:09:48 by jwe]
jwe
parents: 6257
diff changeset
537 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
538
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
539 ## Use axis which is appropriate for legend location.
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
540 ## This is only necessary for plotyy figures where there are two axes.
24335
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
541 if (numel (ca) == 1)
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
542 cax = ca(1);
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
543 elseif (strfind (location, "east"))
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
544 cax = ca(2);
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
545 else
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
546 cax = ca(1);
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
547 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
548 ## Get axis size and fontsize in points.
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
549 ## Rely on listener to handle conversion.
24335
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
550 units = get (cax, "units");
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
551 unwind_protect
24335
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
552 set (cax, "units", "points");
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
553 set (cax, "fontunits", "points");
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
554 if (isempty (hlegend) || ! isprop (hlegend, "unmodified_axes_position"))
24335
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
555 unmodified_axes_position = get (cax, "position");
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
556 unmodified_axes_outerposition = get (cax, "outerposition");
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
557 else
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
558 unmodified_axes_position = get (hlegend, "unmodified_axes_position");
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
559 unmodified_axes_outerposition = get (hlegend, ...
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
560 "unmodified_axes_outerposition");
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
561 endif
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
562 ca_pos = unmodified_axes_position;
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
563 ca_outpos = unmodified_axes_outerposition;
16910
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
564 tightinset = get (ca(1), "tightinset");
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
565 for i = 2 : numel (ca)
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
566 tightinset = max (tightinset, get (ca(i), "tightinset"));
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
567 endfor
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
568 unwind_protect_cleanup
24335
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
569 set (cax, "units", units);
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
570 end_unwind_protect
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
571
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
572 ## Padding between legend entries horizontally and vertically
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
573 xpad = 2;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
574 ypad = 2;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
575
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
576 linelength = 15;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
577
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
578 ## Preamble code to restore figure and axes after legend creation
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
579 origfig = get (0, "currentfigure");
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
580 if (origfig != hfig)
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
581 set (0, "currentfigure", hfig);
18647
ce36233e4849 legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents: 18644
diff changeset
582 else
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
583 origfig = [];
18647
ce36233e4849 legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents: 18644
diff changeset
584 endif
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
585 origaxes = get (hfig, "currentaxes");
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
586 unwind_protect
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
587 ud = ancestor (hplots, "axes");
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
588 if (! isscalar (ud))
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
589 ud = unique ([ud{:}]);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
590 endif
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
591 hpar = get (ud(1), "parent");
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
592
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
593 if (isempty (hlegend))
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
594 ## Create a legend object (axes + new properties)
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
595 addprops = true;
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
596 hlegend = axes ("parent", hpar, "tag", "legend",
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12437
diff changeset
597 "box", box,
14529
aabdc8f281f1 legend.m: Change default to boxon for Matlab compatibility (bug #36105).
Rik <octave@nomad.inbox5.com>
parents: 14375
diff changeset
598 "xtick", [], "ytick", [],
14578
f579a94aacaa Preserve legend handle when changing properties (Bug # 36259).
Carnë Draug <carandraug+dev@gmail.com>
parents: 14552
diff changeset
599 "xlim", [0, 1], "ylim", [0, 1],
20286
42b7d7758c4a Remove axes "interpreter" property (bug #45388)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20231
diff changeset
600 "activepositionproperty", "position");
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
601 setappdata (hlegend, "__axes_handle__", ud);
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
602 try
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
603 addproperty ("__legend_handle__", ud(1), "handle", hlegend);
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
604 catch
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
605 set (ud(1), "__legend_handle__", hlegend);
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
606 end_try_catch
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
607
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
608 ## Inherit fontsize from current axis
24335
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
609 ## "fontunits" should be first because it affects interpretation
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
610 ## of "fontsize" property.
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
611 [fontunits, fontsz] = get (ca(1), {"fontunits", "fontsize"}){:};
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
612 fontsz *= 0.90; # Reduce legend fontsize to 90% of axes fontsize
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
613 set (hlegend, {"fontunits", "fontsize"}, {fontunits, fontsz});
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
614 set (hlegend, "fontunits", "points"); # legend always works in pts.
20408
71bd638e0ef6 legend.m: Fix listeners on legend line objects (bug #45563).
Rik <rik@octave.org>
parents: 20286
diff changeset
615 old_hplots = [];
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
616 else
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
617 ## Re-use existing legend.
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
618 addprops = false;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
619 axes (hlegend);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
620 delete (get (hlegend, "children"));
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
621 ## Hack: get list of hplots for which addlistener has been called.
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
622 old_hplots = get (hlegend, "deletefcn"){6};
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
623 endif
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
624
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
625 if (addprops)
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
626 ## Only required for a newly created legend object
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
627 ## FIXME: "autoupdate" is not implemented.
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
628 addproperty ("autoupdate", hlegend, "radio", "{on}|off");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
629 addproperty ("edgecolor", hlegend, "color", [0.15, 0.15, 0.15]);
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
630 addproperty ("textcolor", hlegend, "color", [0, 0, 0]);
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
631 locations = {"north", "south", "east", "west", ...
17536
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
632 "{northeast}", "southeast", "northwest", "southwest", ...
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
633 "northoutside", "southoutside", ...
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
634 "eastoutside", "westoutside", ...
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
635 "northeastoutside", "southeastoutside", ...
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
636 "northwestoutside", "southwestoutside", "best", ...
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
637 "bestoutside", "none"};
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
638 addproperty ("location", hlegend, "radio", strjoin (locations, "|"));
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
639 addproperty ("orientation", hlegend, "radio",
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
640 "{vertical}|horizontal");
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
641 addproperty ("string", hlegend, "any", text_strings);
20286
42b7d7758c4a Remove axes "interpreter" property (bug #45388)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20231
diff changeset
642 addproperty ("interpreter", hlegend, "textinterpreter");
17536
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
643 addproperty ("textposition", hlegend, "radio", "left|{right}");
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
644 endif
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
645
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
646 ## Apply any PROPERTY/VALUE pairs given as arguments
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
647 if (! isempty (propvals))
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
648 set (hlegend, propvals{:});
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
649 endif
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
650
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
651 ## Text objects in key inherit visual properties from legend object
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
652 legprops = { "fontunits", "fontangle", "fontname", "fontsize", ...
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
653 "fontweight", "interpreter", "textcolor" };
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
654
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
655 txtprops = { "fontunits", [], "fontangle", [] "fontname", [], ...
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
656 "fontsize", [], "fontweight", [] "interpreter", [], ...
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
657 "color", [] };
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
658 propvals = get (hlegend, legprops);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
659 txtprops(2:2:end) = propvals;
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
660
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
661 ## Add text labels to the axes first and check their extents
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
662 nentries = numel (hplots);
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
663 texthandle = [];
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
664 maxwidth = maxheight = 0;
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
665 for k = 1 : nentries
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
666 halign = ifelse (strcmp (textpos, "right"), "left", "right");
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
667 texthandle(k) = text (0, 0, text_strings{k},
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
668 "units", "points",
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
669 "horizontalalignment", halign,
24472
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
670 txtprops{:});
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
671 setappdata (texthandle(k), "handle", hplots(k));
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
672 extents = get (texthandle(k), "extent");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
673 maxwidth = max (maxwidth, extents(3));
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
674 maxheight = max (maxheight, extents(4));
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
675 endfor
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
676 ## Restore units which were force to points
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
677 set (texthandle, "units", get (0, "DefaultTextUnits"));
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
678
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
679 num1 = nentries;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
680 if (strcmp (orientation, "vertical"))
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
681 height = nentries * (ypad + maxheight);
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
682 if (outside)
15440
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
683 if (height > ca_pos(4))
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
684 ## Avoid shrinking the height of the axis to zero if outside
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
685 num1 = ca_pos(4) / (maxheight + ypad) / 2;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
686 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
687 else
15440
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
688 if (height > 0.9 * ca_pos(4))
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
689 num1 = 0.9 * ca_pos(4) / (maxheight + ypad);
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
690 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
691 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
692 else
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
693 width = nentries * (ypad + maxwidth);
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
694 if (outside)
15440
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
695 if (width > ca_pos(3))
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
696 ## Avoid shrinking the width of the axis to zero if outside
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
697 num1 = ca_pos(3) / (maxwidth + ypad) / 2;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
698 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
699 else
15440
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
700 if (width > 0.9 * ca_pos(3))
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
701 num1 = 0.9 * ca_pos(3) / (maxwidth + ypad);
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
702 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
703 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
704 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
705 num2 = ceil (nentries / num1);
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
706
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
707 xstep = 3 * xpad + (maxwidth + linelength);
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
708 if (strcmp (textpos, "right"))
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
709 xoffset = xpad;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
710 txoffset = 2 * xpad + linelength;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
711 else
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
712 xoffset = 2 * xpad + maxwidth;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
713 txoffset = xpad + maxwidth;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
714 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
715 ystep = (ypad + maxheight);
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
716 yoffset = ystep / 2;
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
717
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
718 ## Place the legend in the desired location
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
719 if (strcmp (orientation, "vertical"))
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
720 lpos = [0, 0, num2 * xstep, num1 * ystep];
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
721 else
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
722 lpos = [0, 0, num1 * xstep, num2 * ystep];
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
723 endif
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
724
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
725 gnuplot = strcmp (get (hfig, "__graphics_toolkit__"), "gnuplot");
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
726 if (gnuplot)
24335
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
727 ## gnuplot places the key (legend) at edge of the figure window.
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
728 ## OpenGL places the legend box at edge of the unmodified axes
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
729 ## position.
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
730 if (isempty (strfind (location, "east")))
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
731 gnuplot_offset = unmodified_axes_outerposition(1) ...
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
732 + unmodified_axes_outerposition(3) ...
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
733 - unmodified_axes_position(1) ...
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
734 - unmodified_axes_position(3);
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
735 else
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
736 gnuplot_offset = unmodified_axes_position(1) ...
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
737 - unmodified_axes_outerposition(1);
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
738 endif
17179
828e8852efa9 legend.m: Add %!demo block showing bug #39697.
Rik <rik@octave.org>
parents: 17174
diff changeset
739 ## FIXME: The "fontsize" is added to match the behavior of OpenGL.
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
740 ## This implies that a change in fontsize should trigger a listener
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
741 ## to update the legend. The "2" was determined using a long legend
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
742 ## key in the absence of any subplots.
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
743 gnuplot_offset -= 2 * get (hlegend, "fontsize");
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
744 else
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
745 gnuplot_offset = 0;
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
746 endif
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
747
24335
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
748 ## For legend's outside the associated axes position,
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
749 ## align their edge to the unmodified_axes_outerposition,
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
750 ## and adjust the axes position accordingly.
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
751 switch (location)
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
752 case "north"
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
753 if (outside)
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
754 lpos = [ca_pos(1) + (ca_pos(3) - lpos(3)) / 2, ...
12396
6ba430a75553 Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents: 12395
diff changeset
755 ca_outpos(2) + ca_outpos(4) - lpos(4) - ypad, lpos(3), ...
6ba430a75553 Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents: 12395
diff changeset
756 lpos(4)];
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
757
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
758 new_pos = [ca_pos(1), ca_pos(2), ca_pos(3), ca_pos(4) - lpos(4)];
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
759 else
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
760 lpos = [ca_pos(1) + (ca_pos(3) - lpos(3)) / 2, ...
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
761 ca_pos(2) + ca_pos(4) - lpos(4) - ypad, lpos(3), lpos(4)];
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
762 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
763 case "south"
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
764 if (outside)
12396
6ba430a75553 Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents: 12395
diff changeset
765 lpos = [ca_pos(1) + (ca_pos(3) - lpos(3)) / 2, ...
6ba430a75553 Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents: 12395
diff changeset
766 ca_outpos(2) + ypad, lpos(3), lpos(4)];
16910
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
767 new_pos = [ca_pos(1), lpos(2) + lpos(4) + 2 * ypad ...
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
768 + tightinset(2), ca_pos(3), ...
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
769 ca_pos(4) - lpos(4)];
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
770 else
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
771 lpos = [ca_pos(1) + (ca_pos(3) - lpos(3)) / 2, ...
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
772 ca_pos(2) + ypad, lpos(3), lpos(4)];
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
773 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
774 case "east"
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
775 if (outside)
12396
6ba430a75553 Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents: 12395
diff changeset
776 lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3) - ypad, ...
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
777 ca_pos(2) + (ca_pos(4) - lpos(4)) / 2, lpos(3), lpos(4)];
16910
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
778 new_pos = [ca_pos(1), ca_pos(2), ...
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
779 lpos(1) - 2 * xpad - ca_pos(1) - tightinset(3), ...
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
780 ca_pos(4)];
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
781 new_pos(3) = new_pos(3) + gnuplot_offset;
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
782 else
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
783 lpos = [ca_pos(1) + ca_pos(3) - lpos(3) - ypad, ...
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
784 ca_pos(2) + (ca_pos(4) - lpos(4)) / 2, lpos(3), lpos(4)];
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
785 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
786 case "west"
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
787 if (outside)
12396
6ba430a75553 Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents: 12395
diff changeset
788 lpos = [ca_outpos(1) + ypad, ...
6ba430a75553 Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents: 12395
diff changeset
789 ca_pos(2) + (ca_pos(4) - lpos(4)) / 2, ...
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
790 lpos(3), lpos(4)];
16910
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
791 new_pos = [lpos(1) + lpos(3) + 2 * xpad + tightinset(1), ...
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
792 ca_pos(2), ca_pos(3) - lpos(3) - 2 * xpad, ca_pos(4)];
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
793 new_pos(1) = new_pos(1) - gnuplot_offset;
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
794 new_pos(3) = new_pos(3) + gnuplot_offset;
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
795 else
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
796 lpos = [ca_pos(1) + ypad, ...
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
797 ca_pos(2) + (ca_pos(4) - lpos(4)) / 2, lpos(3), lpos(4)];
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
798 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
799 case "northeast"
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
800 if (outside)
12396
6ba430a75553 Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents: 12395
diff changeset
801 lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3) - ypad, ...
12395
4d30b4136a3e legend.m: Align legends to plot box, add demo. Bug 32373.
Ben Abbott <bpabbott@mac.com>
parents: 12394
diff changeset
802 ca_pos(2) + ca_pos(4) - lpos(4), lpos(3), lpos(4)];
16910
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
803 new_pos = [ca_pos(1), ca_pos(2), ...
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
804 lpos(1) - 2 * xpad - tightinset(3) - ca_pos(1), ...
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
805 ca_pos(4)];
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
806 new_pos(3) = new_pos(3) + gnuplot_offset;
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
807 else
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
808 lpos = [ca_pos(1) + ca_pos(3) - lpos(3) - ypad, ...
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
809 ca_pos(2) + ca_pos(4) - lpos(4) - ypad, lpos(3), lpos(4)];
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
810 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
811 case "northwest"
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
812 if (outside)
12396
6ba430a75553 Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents: 12395
diff changeset
813 lpos = [ca_outpos(1) + ypad , ca_pos(2) + ca_pos(4) - lpos(4), ...
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
814 lpos(3), lpos(4)];
16910
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
815 new_pos = [lpos(1) + lpos(3) + 2 * xpad + tightinset(1), ...
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
816 ca_pos(2), ca_pos(3) - lpos(3) - 2 * xpad, ca_pos(4)];
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
817 new_pos(1) = new_pos(1) - gnuplot_offset;
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
818 new_pos(3) = new_pos(3) + gnuplot_offset;
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
819 else
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
820 lpos = [ca_pos(1) + ypad, ...
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
821 ca_pos(2) + ca_pos(4) - lpos(4) - ypad, lpos(3), lpos(4)];
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
822 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
823 case "southeast"
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
824 if (outside)
12396
6ba430a75553 Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents: 12395
diff changeset
825 lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3) - ypad, ...
6ba430a75553 Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents: 12395
diff changeset
826 ca_pos(2), lpos(3), lpos(4)];
12395
4d30b4136a3e legend.m: Align legends to plot box, add demo. Bug 32373.
Ben Abbott <bpabbott@mac.com>
parents: 12394
diff changeset
827 new_pos = [ca_pos(1), ca_pos(2), ...
16910
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
828 lpos(1) - 2 * xpad - ca_pos(1) - tightinset(3), ...
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
829 ca_pos(4)];
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
830 new_pos(3) = new_pos(3) + gnuplot_offset;
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
831 else
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
832 lpos = [ca_pos(1) + ca_pos(3) - lpos(3) - ypad, ...
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
833 ca_pos(2) + ypad, lpos(3), lpos(4)];
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
834 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
835 case "southwest"
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
836 if (outside)
12396
6ba430a75553 Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents: 12395
diff changeset
837 lpos = [ca_outpos(1) + ypad, ca_pos(2), lpos(3), lpos(4)];
16910
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
838 new_pos = [lpos(1) + lpos(3) + 2 * xpad + tightinset(1), ...
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
839 ca_pos(2), ca_pos(3) - lpos(3) - 2 * xpad, ca_pos(4)];
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
840 new_pos(1) = new_pos(1) - gnuplot_offset;
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
841 new_pos(3) = new_pos(3) + gnuplot_offset;
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
842 else
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
843 lpos = [ca_pos(1) + ypad, ca_pos(2) + ypad, lpos(3), lpos(4)];
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
844 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
845 endswitch
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
846
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
847 units = get (hlegend, "units");
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
848 unwind_protect
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
849 set (hlegend, "units", "points");
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12437
diff changeset
850 set (hlegend, "position", lpos);
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
851 unwind_protect_cleanup
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
852 set (hlegend, "units", units);
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
853 end_unwind_protect
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
854
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
855 ## Now write the line segments and place the text objects correctly
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
856 xk = yk = 0;
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
857 for k = 1 : numel (hplots)
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
858 hobjects(end+1) = texthandle(k);
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
859 hplt = hplots(k);
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
860 typ = get (hplt, "type");
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
861 ## For an hggroup, find an underlying primitive object
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
862 if (strcmp (typ, "hggroup"))
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
863 for hgkid = get (hplt, "children").'
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
864 hgkid_type = get (hgkid, "type");
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
865 if (any (strcmp (hgkid_type, {"line","patch","surface"})))
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
866 typ = hgkid_type;
21937
55f7de37b618 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 21904
diff changeset
867 hplt = hgkid;
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
868 break;
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
869 endif
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
870 endfor
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
871 endif
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
872
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
873 switch (typ)
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
874
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
875 case "line"
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
876 color = get (hplt, "color");
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
877 style = get (hplt, "linestyle");
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
878 lwidth = min (get (hplt, "linewidth"), 5);
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
879 if (! strcmp (style, "none"))
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
880 l1 = line ("xdata", ([xoffset, xoffset + linelength] + xk * xstep) / lpos(3),
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
881 "ydata", [1, 1] .* (lpos(4) - yoffset - yk * ystep) / lpos(4),
18422
be3702a2eb8a legend.m: use linewidth from plot object in drawing legend (bug #41283)
Joachim Wiesemann <gnu@jwiesemann.com>
parents: 17885
diff changeset
882 "color", color, "linestyle", style, "linewidth", lwidth,
24472
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
883 "marker", "none");
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
884 setappdata (l1, "handle", hplt);
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
885 hobjects(end+1) = l1;
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
886 endif
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
887 marker = get (hplt, "marker");
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
888 if (! strcmp (marker, "none"))
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
889 l1 = line ("xdata", (xoffset + 0.5 * linelength + xk * xstep) / lpos(3),
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
890 "ydata", (lpos(4) - yoffset - yk * ystep) / lpos(4),
18422
be3702a2eb8a legend.m: use linewidth from plot object in drawing legend (bug #41283)
Joachim Wiesemann <gnu@jwiesemann.com>
parents: 17885
diff changeset
891 "color", color, "linestyle", "none", "linewidth", lwidth,
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
892 "marker", marker,
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
893 "markeredgecolor", get (hplt, "markeredgecolor"),
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
894 "markerfacecolor", get (hplt, "markerfacecolor"),
24472
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
895 "markersize", min (get (hplt, "markersize"),10));
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
896 setappdata (l1, "handle", hplt);
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
897 hobjects(end+1) = l1;
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
898 endif
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
899
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
900 ## Newly labeled objects have listeners added
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
901 if (! any (hplt == old_hplots))
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
902 addlistener (hplt, "color",
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
903 {@cb_line_listener, hlegend, linelength, false});
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
904 addlistener (hplt, "linestyle",
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
905 {@cb_line_listener, hlegend, linelength, false});
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
906 addlistener (hplt, "linewidth",
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
907 {@cb_line_listener, hlegend, linelength, false});
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
908 addlistener (hplt, "marker",
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
909 {@cb_line_listener, hlegend, linelength, false});
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
910 addlistener (hplt, "markeredgecolor",
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
911 {@cb_line_listener, hlegend, linelength, false});
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
912 addlistener (hplt, "markerfacecolor",
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
913 {@cb_line_listener, hlegend, linelength, false});
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
914 addlistener (hplt, "markersize",
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
915 {@cb_line_listener, hlegend, linelength, false});
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
916 addlistener (hplt, "displayname",
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
917 {@cb_line_listener, hlegend, linelength, true});
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
918 endif
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
919
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
920 case "patch"
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
921 facecolor = get (hplt, "facecolor");
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
922 edgecolor = get (hplt, "edgecolor");
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
923 cdata = get (hplt, "cdata");
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
924 if (! strcmp (facecolor, "none") || ! strcmp (edgecolor, "none"))
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
925 p1 = patch ("xdata", ([0, linelength, linelength, 0] +
17536
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
926 xoffset + xk * xstep) / lpos(3),
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
927 "ydata", (lpos(4) - yoffset -
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
928 [yk-0.3, yk-0.3, yk+0.3, yk+0.3] .* ystep) / lpos(4),
18564
3a1a4d587c4e legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents: 18423
diff changeset
929 "facecolor", facecolor, "edgecolor", edgecolor,
24472
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
930 "cdata", cdata);
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
931 setappdata (p1, "handle", hplt);
18564
3a1a4d587c4e legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents: 18423
diff changeset
932 else
3a1a4d587c4e legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents: 18423
diff changeset
933 ## non-standard patch only making use of marker styles
3a1a4d587c4e legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents: 18423
diff changeset
934 ## such as scatter plot.
3a1a4d587c4e legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents: 18423
diff changeset
935 p1 = patch ("xdata", (xoffset + 0.5 * linelength + xk * xstep) / lpos(3),
3a1a4d587c4e legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents: 18423
diff changeset
936 "ydata", (lpos(4) - yoffset - yk * ystep) / lpos(4),
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
937 "marker", get (hplt, "marker"),
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
938 "markeredgecolor",get (hplt,"markeredgecolor"),
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
939 "markerfacecolor",get (hplt,"markerfacecolor"),
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
940 "markersize", min (get (hplt,"markersize"),10),
24472
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
941 "cdata", cdata);
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
942 setappdata (p1, "handle", hplt);
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
943 endif
18564
3a1a4d587c4e legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents: 18423
diff changeset
944 hobjects(end+1) = p1;
3a1a4d587c4e legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents: 18423
diff changeset
945 ## Copy clim from axes so that colors work out.
3a1a4d587c4e legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents: 18423
diff changeset
946 set (hlegend, "clim", get (ca(1), "clim"));
3a1a4d587c4e legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents: 18423
diff changeset
947
3a1a4d587c4e legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents: 18423
diff changeset
948 ## FIXME: Need listeners, as for line objects.
17730
580990c2ce04 legend.m: Fix legend color for bar graphs (bug #40327)
Rik <rik@octave.org>
parents: 17677
diff changeset
949 ## Changing clim, for example, won't update colors
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
950
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
951 case "surface"
21904
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
952 facecolor = get (hplt, "facecolor");
7aa8d9c28d2b legend.m: Return the correct third argument (h_plots) when plot has hggroups (bug #48210).
Rik <rik@octave.org>
parents: 21898
diff changeset
953 edgecolor = get (hplt, "edgecolor");
17560
225ec9a0222a legend.m: Use axis that legend refers to when calculating color for surface patch label.
Rik <rik@octave.org>
parents: 17540
diff changeset
954 cdata = sum (get (ca(1), "clim")) / 2;
17540
b7aa1d726bcc legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents: 17538
diff changeset
955 if (! strcmp (facecolor, "none") || ! strcmp (edgecolor, "none"))
b7aa1d726bcc legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents: 17538
diff changeset
956 p1 = patch ("xdata", ([0, linelength, linelength, 0] +
b7aa1d726bcc legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents: 17538
diff changeset
957 xoffset + xk * xstep) / lpos(3),
b7aa1d726bcc legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents: 17538
diff changeset
958 "ydata", (lpos(4) - yoffset -
b7aa1d726bcc legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents: 17538
diff changeset
959 [yk-0.3, yk-0.3, yk+0.3, yk+0.3] .* ystep) / lpos(4),
18564
3a1a4d587c4e legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents: 18423
diff changeset
960 "facecolor", facecolor, "edgecolor", edgecolor,
24472
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
961 "cdata", cdata);
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
962 setappdata (p1, "handle", hplt);
17540
b7aa1d726bcc legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents: 17538
diff changeset
963 hobjects(end+1) = p1;
b7aa1d726bcc legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents: 17538
diff changeset
964 endif
18564
3a1a4d587c4e legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents: 18423
diff changeset
965 ## FIXME: Need listeners, as for line objects.
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
966
10999
9f45b76c16e3 legend.m: Treat line, patch, and surface objects differetly.
Ben Abbott <bpabbott@mac.com>
parents: 10995
diff changeset
967 endswitch
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
968
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
969 set (texthandle(k), "position",
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
970 [(txoffset + xk * xstep) / lpos(3), ...
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
971 (lpos(4) - yoffset - yk * ystep) / lpos(4)]);
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
972 if (strcmp (orientation, "vertical"))
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20711
diff changeset
973 yk += 1;
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
974 if (yk > num1)
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
975 yk = 0;
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20711
diff changeset
976 xk += 1;
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
977 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
978 else
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20711
diff changeset
979 xk += 1;
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
980 if (xk > num1)
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
981 xk = 0;
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20711
diff changeset
982 yk += 1;
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
983 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
984 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
985 endfor
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
986
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
987 ## Add an invisible text object to original axis
24335
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
988 ## that, when it is destroyed, will remove the legend.
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
989 htdel = findall (ca(1), "-depth", 1, "tag", "deletelegend",
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
990 "type", "text");
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
991 if (isempty (htdel))
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
992 htdel = text (0, 0, "", "parent", ca(1), "tag", "deletelegend",
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
993 "visible", "off", "handlevisibility", "off",
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
994 "xliminclude", "off", "yliminclude", "off",
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
995 "zliminclude", "off");
24482
b4e371b5f6b5 Fix shrinking plots when colorbar or legend in "outside" location (bug #52732).
Rik <rik@octave.org>
parents: 24478
diff changeset
996 set (htdel, "deletefcn", {@cb_axes_deleted, ca, hlegend});
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
997 endif
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
998 if (isprop (hlegend, "unmodified_axes_position"))
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
999 set (hlegend, "unmodified_axes_position",
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1000 unmodified_axes_position,
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1001 "unmodified_axes_outerposition",
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1002 unmodified_axes_outerposition);
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1003 else
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1004 addproperty ("unmodified_axes_position", hlegend,
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1005 "data", unmodified_axes_position);
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1006 addproperty ("unmodified_axes_outerposition", hlegend,
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1007 "data", unmodified_axes_outerposition);
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1008 endif
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1009
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1010 ## Resize the axis that the legend is attached to if the legend is
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1011 ## "outside" the plot and create a listener to resize axis to original
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1012 ## size if the legend is deleted, hidden, or shown.
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1013 if (outside)
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1014 for i = 1 : numel (ca)
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1015 units = get (ca(i), "units");
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1016 unwind_protect
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1017 set (ca(i), "units", "points");
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
1018 if (gnuplot && numel (ca) == 1)
24335
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
1019 ## Let gnuplot handle the positioning of the keybox.
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
1020 ## This violates strict Matlab compatibility, but reliably
24335
8edaf9c80779 Fix legend placement for plotyy figures (bug #52547).
Rik <rik@octave.org>
parents: 23573
diff changeset
1021 ## renders an aesthetic result.
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
1022 set (ca(i), "position", unmodified_axes_position);
21385
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20852
diff changeset
1023 set (ca(i), "activepositionproperty", "outerposition");
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
1024 else
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
1025 ## numel (ca) > 1 for axes overlays (like plotyy)
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
1026 set (ca(i), "position", new_pos);
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
1027 endif
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1028 unwind_protect_cleanup
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1029 set (ca(i), "units", units);
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1030 end_unwind_protect
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1031 endfor
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1032
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1033 set (hlegend, "deletefcn", {@cb_restore_axes, ca, ...
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1034 unmodified_axes_position, ...
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
1035 unmodified_axes_outerposition, ...
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1036 htdel, hplots});
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1037 addlistener (hlegend, "visible", {@cb_legend_hideshow, ca, ...
16909
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
1038 unmodified_axes_position, ...
8f9ed9d8a478 Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents: 16908
diff changeset
1039 new_pos});
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1040 else
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1041 set (hlegend, "deletefcn", {@cb_restore_axes, ca, [], [], ...
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1042 htdel, hplots});
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1043 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1044
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
1045 if (! addprops)
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1046 ## Remove listeners on existing legend temporarily to stop recursion.
17536
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
1047 dellistener (hlegend, "location");
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
1048 dellistener (hlegend, "orientation");
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
1049 dellistener (hlegend, "string");
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
1050 dellistener (hlegend, "textposition");
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
1051 endif
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
1052
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
1053 if (! addprops)
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1054 set (hlegend, "string", text_strings);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1055 endif
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1056
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1057 if (outside)
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
1058 set (hlegend, "location", [location "outside"],
17536
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
1059 "orientation", orientation, "textposition", textpos);
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1060 else
16796
519343308ab1 Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents: 16795
diff changeset
1061 set (hlegend, "location", location, "orientation", orientation,
17536
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
1062 "textposition", textpos);
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1063 endif
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1064
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1065 if (addprops)
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1066 addlistener (hlegend, "edgecolor", @cb_legend_text_update);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1067 addlistener (hlegend, "fontangle", @cb_legend_text_update);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1068 addlistener (hlegend, "fontname", @cb_legend_text_update);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1069 addlistener (hlegend, "fontweight", @cb_legend_text_update);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1070 addlistener (hlegend, "textcolor", @cb_legend_text_update);
17536
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
1071 ## Properties which could change size of box, such as fontsize,
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
1072 ## require legend to be redrawn.
17885
1d109119ac71 legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents: 17744
diff changeset
1073 ## FIXME: fontsize is changed by print.m function during the
1d109119ac71 legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents: 17744
diff changeset
1074 ## production of a plot for output. This screws things up
1d109119ac71 legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents: 17744
diff changeset
1075 ## because legend tries to return the axes size to what it
1d109119ac71 legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents: 17744
diff changeset
1076 ## was when the figure was created, versus what it is now
1d109119ac71 legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents: 17744
diff changeset
1077 ## when the figure is being printed. Temporary hack is
1d109119ac71 legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents: 17744
diff changeset
1078 ## good enough for generating the Octave manual which still
1d109119ac71 legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents: 17744
diff changeset
1079 ## relies on gnuplot for generating images. See bug #40333.
1d109119ac71 legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents: 17744
diff changeset
1080 if (! gnuplot)
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1081 addlistener (hlegend, "fontsize", @cb_legend_update);
17885
1d109119ac71 legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents: 17744
diff changeset
1082 endif
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1083 addlistener (hlegend, "fontunits", @cb_legend_update);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1084 addlistener (hlegend, "interpreter", @cb_legend_update);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1085 addlistener (hlegend, "location", @cb_legend_location);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1086 addlistener (hlegend, "orientation", @cb_legend_update);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1087 addlistener (hlegend, "string", @cb_legend_update);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1088 addlistener (hlegend, "textposition", @cb_legend_update);
17536
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
1089 ## FIXME: need to add listeners for tightinset and position
16910
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
1090 ## addlistener (ca, "tightinset", @update????);
8a4e53cf79c9 Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents: 16909
diff changeset
1091 ## addlistener (ca, "position", @update????);
17536
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
1092 else
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1093 ## Restore listeners temporarily disabled during reconstruction.
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1094 addlistener (hlegend, "location", @cb_legend_update);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1095 addlistener (hlegend, "orientation", @cb_legend_update);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1096 addlistener (hlegend, "string", @cb_legend_update);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1097 addlistener (hlegend, "textposition", @cb_legend_update);
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1098 endif
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
1099
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1100 unwind_protect_cleanup
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
1101 set (hfig, "currentaxes", origaxes);
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
1102 if (! isempty (origfig))
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
1103 set (0, "currentfigure", origfig);
18647
ce36233e4849 legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents: 18644
diff changeset
1104 endif
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1105 end_unwind_protect
6272
a1f3d3b7ee5c [project @ 2007-02-06 02:09:48 by jwe]
jwe
parents: 6257
diff changeset
1106 endif
6147
e14b0e9b7bf7 [project @ 2006-11-09 03:28:01 by jwe]
jwe
parents: 6146
diff changeset
1107 endif
e14b0e9b7bf7 [project @ 2006-11-09 03:28:01 by jwe]
jwe
parents: 6146
diff changeset
1108
24403
b9462090773a legend.m: Setting DisplayName to "" should delete legend (bug #52641).
Rik <rik@octave.org>
parents: 24399
diff changeset
1109 ## Restore operation of callbacks
24472
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1110 setappdata (hlegend, "nocallbacks", false);
24403
b9462090773a legend.m: Setting DisplayName to "" should delete legend (bug #52641).
Rik <rik@octave.org>
parents: 24399
diff changeset
1111
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1112 if (nargout > 0)
17503
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
1113 hleg = hlegend;
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
1114 hleg_obj = hobjects;
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
1115 hplot = hplots;
d99785217634 legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents: 17281
diff changeset
1116 labels = text_strings;
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1117 endif
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1118
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1119 endfunction
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1120
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1121 ## A non-text property of legend has changed requiring an update.
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1122 function cb_legend_update (hleg, ~)
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1123 persistent recursive = false;
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
1124
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1125 if (! recursive)
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1126 recursive = true;
12339
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents: 11587
diff changeset
1127 unwind_protect
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
1128 hax = getappdata (hleg, "__axes_handle__");
24464
359596cc55dd Fix ordering of legend objects when updated via callback (bug #46835).
Rik <rik@octave.org>
parents: 24434
diff changeset
1129 ## Hack. Maybe store this somewhere else such as appdata.
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
1130 hplots = get (hleg, "deletefcn"){6};
24464
359596cc55dd Fix ordering of legend objects when updated via callback (bug #46835).
Rik <rik@octave.org>
parents: 24434
diff changeset
1131 text_strings = get (hleg, "string");
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1132 position = get (hleg, "unmodified_axes_position");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1133 outerposition = get (hleg, "unmodified_axes_outerposition");
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1134 units = get (hax, "units");
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
1135 set (hax, "units", "points");
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16921
diff changeset
1136 switch (get (hax, "activepositionproperty"))
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
1137 case "position"
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
1138 set (hax, "outerposition", outerposition);
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
1139 set (hax, "position", position);
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
1140 case "outerposition"
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
1141 set (hax, "position", position);
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17125
diff changeset
1142 set (hax, "outerposition", outerposition);
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1143 endswitch
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1144 if (isscalar (hax))
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1145 set (hax, "units", units);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1146 else
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1147 set (hax, {"units"}, units);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1148 endif
18644
8c0646dd9e5a legend.m: Fix bug updating plotyy figures (bug #41970).
Rik <rik@octave.org>
parents: 18564
diff changeset
1149
24464
359596cc55dd Fix ordering of legend objects when updated via callback (bug #46835).
Rik <rik@octave.org>
parents: 24434
diff changeset
1150 hleg = legend (hax(1), hplots, text_strings);
12339
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents: 11587
diff changeset
1151 unwind_protect_cleanup
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents: 11587
diff changeset
1152 recursive = false;
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents: 11587
diff changeset
1153 end_unwind_protect
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1154 endif
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
1155
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1156 endfunction
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1157
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1158 ## A text property of legend, such as fontname, has changed.
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1159 function cb_legend_text_update (hleg, ~)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
1160
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1161 kids = get (hleg, "children");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1162 htext = kids(strcmp (get (kids, "type"), "text"));
17533
bb7756dff055 legend.m: Add listeners for all font properties to update text labels.
Rik <rik@octave.org>
parents: 17532
diff changeset
1163
17536
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
1164 tprops = {"fontangle", "fontname", "fontweight", "color"};
8a186cd5b9a6 legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents: 17535
diff changeset
1165 lprops = {"fontangle", "fontname", "fontweight", "textcolor"};
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1166 set (htext, tprops, get (hleg, lprops));
17535
5eae41c8c07f legend.m: Add support for "edgecolor" property.
Rik <rik@octave.org>
parents: 17534
diff changeset
1167
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1168 ec = get (hleg, "edgecolor");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1169 set (hleg, "xcolor", ec, "ycolor", ec);
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
1170
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1171 endfunction
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1172
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1173 ## The legend "visible" property has changed.
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1174 function cb_legend_hideshow (hleg, ~, ca, orig_pos, new_pos)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
1175
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1176 isvisible = strcmp (get (hleg, "visible"), "on");
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1177
24426
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1178 ## FIXME: Can't use a single set() call because of linked axes and
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1179 ## listeners on plotyy graphs.
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1180 ca = ca(isaxes (ca));
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1181 for cax = ca(:).'
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1182 units = get (cax, "units");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1183 unwind_protect
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1184 set (cax, "units", "points");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1185 if (isvisible)
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1186 set (cax, "position", new_pos);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1187 else
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1188 set (cax, "position", orig_pos);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1189 endif
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1190 unwind_protect_cleanup
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1191 set (cax, "units", units);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1192 end_unwind_protect
10990
529b36293297 Backed out changeset 6ea65c5de87a
David Bateman <dbateman@free.fr>
parents: 10989
diff changeset
1193 endfor
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
1194
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1195 endfunction
10989
6ea65c5de87a Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10949
diff changeset
1196
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1197 ## The legend "location" property has changed.
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1198 function cb_legend_location (hleg, d)
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1199
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1200 ## If it isn't "none", which means manual positioning, then rebuild .
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1201 if (! strcmp (get (hleg, "location"), "none"))
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1202 cb_legend_update (hleg, d);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1203 endif
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1204
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1205 endfunction
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
1206
24482
b4e371b5f6b5 Fix shrinking plots when colorbar or legend in "outside" location (bug #52732).
Rik <rik@octave.org>
parents: 24478
diff changeset
1207 ## Axes to which legend was attached is being deleted/reset. Delete legend.
b4e371b5f6b5 Fix shrinking plots when colorbar or legend in "outside" location (bug #52732).
Rik <rik@octave.org>
parents: 24478
diff changeset
1208 function cb_axes_deleted (~, ~, ca, hlegend)
24426
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1209 if (isaxes (hlegend))
24482
b4e371b5f6b5 Fix shrinking plots when colorbar or legend in "outside" location (bug #52732).
Rik <rik@octave.org>
parents: 24478
diff changeset
1210 if (strcmp (get (ca(1), "beingdeleted"), "on"))
b4e371b5f6b5 Fix shrinking plots when colorbar or legend in "outside" location (bug #52732).
Rik <rik@octave.org>
parents: 24478
diff changeset
1211 ## Axes are being deleted. Disable call to cb_restore_axes.
b4e371b5f6b5 Fix shrinking plots when colorbar or legend in "outside" location (bug #52732).
Rik <rik@octave.org>
parents: 24478
diff changeset
1212 set (hlegend, "deletefcn", []);
b4e371b5f6b5 Fix shrinking plots when colorbar or legend in "outside" location (bug #52732).
Rik <rik@octave.org>
parents: 24478
diff changeset
1213 endif
21652
2e07dcdc6139 legend.m: Check handle is valid before delete (partial fix bug #47699).
Rik <rik@octave.org>
parents: 21580
diff changeset
1214 delete (hlegend);
10989
6ea65c5de87a Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10949
diff changeset
1215 endif
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
1216 endfunction
10989
6ea65c5de87a Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10949
diff changeset
1217
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1218 ## Restore position of axes object when legend is deleted.
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1219 function cb_restore_axes (~, ~, ca, pos, outpos, htdel, hplots)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
1220
24426
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1221 hf = ancestor (ca(1), "figure");
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1222 if (strcmp (get (hf, "beingdeleted"), "on") ||
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1223 strcmp (get (ca(1), "beingdeleted"), "on"))
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1224 ## Skip restoring axes if entire figure or axes is being destroyed.
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1225 return;
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1226 endif
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1227
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1228 ## Remove text object used to trigger legend delete when axes is deleted
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1229 if (ishghandle (htdel))
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1230 set (htdel, "deletefcn", []);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1231 delete (htdel);
24426
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1232 endif
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1233
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1234 ## Restore original axes positions
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1235 if (! isempty (pos))
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1236 ## FIXME: can't use single call to set() because of weirdness w/plotyy
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1237 for cax = ca(:).'
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1238 if (isaxes (cax))
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1239 units = get (cax, "units");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1240 unwind_protect
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1241 set (cax, "units", "points");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1242 set (cax, "position", pos);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1243 unwind_protect_cleanup
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1244 set (cax, "units", units);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1245 end_unwind_protect
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1246 endif
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1247 endfor
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1248 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
1249
24426
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1250 ## Remove listeners from plot objects
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1251 for i = 1 : numel (hplots)
24426
a51497205f4c Change uses of gcbf after Matlab compatibility change in bug #52621.
Rik <rik@octave.org>
parents: 24423
diff changeset
1252 if (isgraphics (hplots(i), "line"))
15440
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
1253 dellistener (hplots(i), "color");
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
1254 dellistener (hplots(i), "linestyle");
18422
be3702a2eb8a legend.m: use linewidth from plot object in drawing legend (bug #41283)
Joachim Wiesemann <gnu@jwiesemann.com>
parents: 17885
diff changeset
1255 dellistener (hplots(i), "linewidth");
15440
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
1256 dellistener (hplots(i), "marker");
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
1257 dellistener (hplots(i), "markeredgecolor");
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
1258 dellistener (hplots(i), "markerfacecolor");
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
1259 dellistener (hplots(i), "markersize");
1db706430c96 Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents: 15202
diff changeset
1260 dellistener (hplots(i), "displayname");
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1261 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1262 endfor
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
1263
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
1264 ## Nullify legend link (can't delete properties yet)
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
1265 set (ca(1), "__legend_handle__", []);
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
1266
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1267 endfunction
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1268
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1269 ## Update legend item because underlying plot line object has changed.
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1270 function cb_line_listener (h, ~, hlegend, linelength, update_name)
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1271
24403
b9462090773a legend.m: Setting DisplayName to "" should delete legend (bug #52641).
Rik <rik@octave.org>
parents: 24399
diff changeset
1272 ## Don't execute callbacks when legend is under construction
24472
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1273 legdata = getappdata (hlegend);
24403
b9462090773a legend.m: Setting DisplayName to "" should delete legend (bug #52641).
Rik <rik@octave.org>
parents: 24399
diff changeset
1274 if (legdata.nocallbacks)
b9462090773a legend.m: Setting DisplayName to "" should delete legend (bug #52641).
Rik <rik@octave.org>
parents: 24399
diff changeset
1275 return;
b9462090773a legend.m: Setting DisplayName to "" should delete legend (bug #52641).
Rik <rik@octave.org>
parents: 24399
diff changeset
1276 endif
b9462090773a legend.m: Setting DisplayName to "" should delete legend (bug #52641).
Rik <rik@octave.org>
parents: 24399
diff changeset
1277
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1278 if (update_name)
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1279 ## When string changes, have to rebuild legend completely
12339
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents: 11587
diff changeset
1280 [hplots, text_strings] = __getlegenddata__ (hlegend);
24403
b9462090773a legend.m: Setting DisplayName to "" should delete legend (bug #52641).
Rik <rik@octave.org>
parents: 24399
diff changeset
1281 if (isempty (hplots))
b9462090773a legend.m: Setting DisplayName to "" should delete legend (bug #52641).
Rik <rik@octave.org>
parents: 24399
diff changeset
1282 delete (hlegend);
b9462090773a legend.m: Setting DisplayName to "" should delete legend (bug #52641).
Rik <rik@octave.org>
parents: 24399
diff changeset
1283 else
24464
359596cc55dd Fix ordering of legend objects when updated via callback (bug #46835).
Rik <rik@octave.org>
parents: 24434
diff changeset
1284 legend (legdata.handle(1), hplots, text_strings);
24398
a7dfb685d261 legend.m: Fix callback error when changing a legend string to "".
Rik <rik@octave.org>
parents: 23257
diff changeset
1285 endif
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1286 else
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1287 kids = get (hlegend, "children");
24472
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1288 kids = kids([getappdata(kids, "handle"){:}] == h);
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1289 kids = kids(strcmp (get (kids, "type"), "line"));
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1290 idx = strcmp (get (kids, "marker"), "none");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1291 ll = kids (idx);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1292 lm = kids (! idx);
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1293
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1294 [linestyle, marker, displayname] = ...
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1295 get (h, {"linestyle", "marker", "displayname"}){:};
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1296
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1297 if (! isempty (ll))
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1298 [xpos1, ypos1] = get (ll, {"xdata", "ydata"}){:};
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1299 xpos2 = sum (xpos1) / 2;
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1300 ypos2 = ypos1(1);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1301 delete (ll);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1302 if (! isempty (lm))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1303 delete (lm);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1304 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1305 else
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1306 [xpos2, ypos2] = get (lm, {"xdata", "ydata"}){:};
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1307 xpos1 = xpos2 + [-0.5, 0.5] * linelength;
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1308 ypos1 = [ypos2, ypos2];
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1309 delete (lm);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1310 endif
17537
4f57d4de0383 legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents: 17536
diff changeset
1311
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1312 if (! strcmp (linestyle, "none"))
24472
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1313 hl = line ("xdata", xpos1, "ydata", ypos1, "color", get (h, "color"),
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1314 "linestyle", get (h, "linestyle"),
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1315 "linewidth", min (get (h, "linewidth"), 5),
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1316 "marker", "none",
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1317 "parent", hlegend);
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1318 setappdata (hl, "handle", h);
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1319 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1320 if (! strcmp (marker, "none"))
24472
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1321 hl = line ("xdata", xpos2, "ydata", ypos2, "color", get (h, "color"),
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1322 "marker", marker, "markeredgecolor", get (h, "markeredgecolor"),
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1323 "markerfacecolor", get (h, "markerfacecolor"),
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1324 "markersize", min (get (h, "markersize"), 10),
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1325 "linestyle", "none",
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1326 "linewidth", min (get (h, "linewidth"), 5),
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1327 "parent", hlegend);
19d63669d174 Don't use "userdata" property internally for legend private data.
Rik <rik@octave.org>
parents: 24464
diff changeset
1328 setappdata (hl, "handle", h);
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1329 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1330 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
1331
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1332 endfunction
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11149
diff changeset
1333
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
1334
11418
a140991387fb legend.m: Add demo to legend for inline key.
Ben Abbott <bpabbott@mac.com>
parents: 11363
diff changeset
1335 %!demo
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
1336 %! clf;
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1337 %! plot (rand (2));
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1338 %! title ("legend called with string inputs for labels");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1339 %! h = legend ("foo", "bar");
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1340 %! legend (h, "location", "northeastoutside");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1341 %! set (h, "fontsize", 20);
11462
aed2c50c3082 legend.m: legend with more than two inline keys (bug 31991). Add/modifyy demos.
Ben Abbott <bpabbott@mac.com>
parents: 11434
diff changeset
1342
aed2c50c3082 legend.m: legend with more than two inline keys (bug 31991). Add/modifyy demos.
Ben Abbott <bpabbott@mac.com>
parents: 11434
diff changeset
1343 %!demo
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
1344 %! clf;
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1345 %! plot (rand (2));
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1346 %! title ("legend called with cell array of strings");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1347 %! h = legend ({"cellfoo", "cellbar"});
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1348 %! legend (h, "location", "northeast");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1349 %! set (h, "fontsize", 20);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1350
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1351 %!demo
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1352 %! clf;
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1353 %! plot (rand (3));
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1354 %! title ("legend () without inputs creates default labels");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1355 %! h = legend ();
14236
35903f035390 Escaping strings for legend entries are handled by __go_draw_axes__.
Ben Abbott <bpabbott@mac.com>
parents: 14214
diff changeset
1356
35903f035390 Escaping strings for legend entries are handled by __go_draw_axes__.
Ben Abbott <bpabbott@mac.com>
parents: 14214
diff changeset
1357 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1358 %! clf;
11418
a140991387fb legend.m: Add demo to legend for inline key.
Ben Abbott <bpabbott@mac.com>
parents: 11363
diff changeset
1359 %! x = 0:1;
22800
5de8670d10a6 Change text describing demo plots to reflect new ColorOrder (bug #49288).
Rik <rik@octave.org>
parents: 22624
diff changeset
1360 %! plot (x,x,";I am Blue;", x,2*x, x,3*x,";I am yellow;");
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1361 %! h = legend ("location", "northeastoutside");
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1362 %! ## Placing legend inside returns axes to original size
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1363 %! legend (h, "location", "northeast");
22800
5de8670d10a6 Change text describing demo plots to reflect new ColorOrder (bug #49288).
Rik <rik@octave.org>
parents: 22624
diff changeset
1364 %! title ("Blue and Yellow keys, with Orange missing");
8343
9f34f7636fe0 legend.m: Correct ording of legend labels.
Ben Abbott <bpabbott@mac.com>
parents: 8291
diff changeset
1365
9f34f7636fe0 legend.m: Correct ording of legend labels.
Ben Abbott <bpabbott@mac.com>
parents: 8291
diff changeset
1366 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1367 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1368 %! plot (1:10, 1:10, 1:10, fliplr (1:10));
22800
5de8670d10a6 Change text describing demo plots to reflect new ColorOrder (bug #49288).
Rik <rik@octave.org>
parents: 22624
diff changeset
1369 %! title ("incline is blue and decline is orange");
5de8670d10a6 Change text describing demo plots to reflect new ColorOrder (bug #49288).
Rik <rik@octave.org>
parents: 22624
diff changeset
1370 %! legend ({"I am blue", "I am orange"}, "location", "east");
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1371 %! legend hide
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1372 %! legend show
11363
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 11246
diff changeset
1373
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 11246
diff changeset
1374 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1375 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1376 %! plot (1:10, 1:10, 1:10, fliplr (1:10));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1377 %! title ("Legend with keys in horizontal orientation");
22800
5de8670d10a6 Change text describing demo plots to reflect new ColorOrder (bug #49288).
Rik <rik@octave.org>
parents: 22624
diff changeset
1378 %! legend ({"I am blue", "I am orange"}, ...
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1379 %! "location", "east", "orientation", "horizontal");
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
1380 %! legend boxoff
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1381 %! legend boxon
11462
aed2c50c3082 legend.m: legend with more than two inline keys (bug 31991). Add/modifyy demos.
Ben Abbott <bpabbott@mac.com>
parents: 11434
diff changeset
1382
aed2c50c3082 legend.m: legend with more than two inline keys (bug 31991). Add/modifyy demos.
Ben Abbott <bpabbott@mac.com>
parents: 11434
diff changeset
1383 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1384 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1385 %! plot (1:10, 1:10, 1:10, fliplr (1:10));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1386 %! title ("Legend with box off");
22800
5de8670d10a6 Change text describing demo plots to reflect new ColorOrder (bug #49288).
Rik <rik@octave.org>
parents: 22624
diff changeset
1387 %! legend ({"I am blue", "I am orange"}, "location", "east");
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
1388 %! legend boxoff
11434
1f54ee6760b5 legend.m: Only one legend per axes (bug 32022)
Ben Abbott <bpabbott@mac.com>
parents: 11418
diff changeset
1389
1f54ee6760b5 legend.m: Only one legend per axes (bug 32022)
Ben Abbott <bpabbott@mac.com>
parents: 11418
diff changeset
1390 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1391 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1392 %! plot (1:10, 1:10, 1:10, fliplr (1:10));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1393 %! title ("Legend with text to the left of key");
22800
5de8670d10a6 Change text describing demo plots to reflect new ColorOrder (bug #49288).
Rik <rik@octave.org>
parents: 22624
diff changeset
1394 %! legend ({"I am blue", "I am orange"}, "location", "east");
17532
492d609d2d75 legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents: 17530
diff changeset
1395 %! legend left
8343
9f34f7636fe0 legend.m: Correct ording of legend labels.
Ben Abbott <bpabbott@mac.com>
parents: 8291
diff changeset
1396
9f34f7636fe0 legend.m: Correct ording of legend labels.
Ben Abbott <bpabbott@mac.com>
parents: 8291
diff changeset
1397 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1398 %! clf;
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1399 %! plot (1:10, 1:10, 1:10, fliplr (1:10));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1400 %! title ({"Use properties to place legend text to the left of key", ...
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1401 %! "Legend text color is magenta"});
22800
5de8670d10a6 Change text describing demo plots to reflect new ColorOrder (bug #49288).
Rik <rik@octave.org>
parents: 22624
diff changeset
1402 %! h = legend ({"I am blue", "I am orange"}, "location", "east");
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1403 %! legend ("right");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1404 %! set (h, "textposition", "left");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1405 %! set (h, "textcolor", [1 0 1]);
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1406
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1407 %!demo
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1408 %! clf;
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1409 %! plot (1:10, 1:10, 1:10, fliplr (1:10));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1410 %! title ("Legend is hidden");
22800
5de8670d10a6 Change text describing demo plots to reflect new ColorOrder (bug #49288).
Rik <rik@octave.org>
parents: 22624
diff changeset
1411 %! legend ({"I am blue", "I am orange"}, "location", "east");
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
1412 %! legend hide
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1413
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1414 %!demo
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1415 %! clf;
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1416 %! x = 0:1;
22800
5de8670d10a6 Change text describing demo plots to reflect new ColorOrder (bug #49288).
Rik <rik@octave.org>
parents: 22624
diff changeset
1417 %! plot (x,x,";I am Blue;", x,2*x,";I am Orange;", x,3*x,";I am Yellow;");
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1418 %! title ({"Labels are embedded in call to plot", ...
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1419 %! "Legend is hidden and then shown"});
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1420 %! legend boxon
11434
1f54ee6760b5 legend.m: Only one legend per axes (bug 32022)
Ben Abbott <bpabbott@mac.com>
parents: 11418
diff changeset
1421 %! legend hide
1f54ee6760b5 legend.m: Only one legend per axes (bug 32022)
Ben Abbott <bpabbott@mac.com>
parents: 11418
diff changeset
1422 %! legend show
11363
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 11246
diff changeset
1423
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 11246
diff changeset
1424 %!demo
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1425 %! clf;
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1426 %! x = 0:1;
22151
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22069
diff changeset
1427 %! plot (x,x, x,2*x, x,3*x);
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1428 %! title ("Labels with interpreted Greek text");
22151
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22069
diff changeset
1429 %! h = legend ('\alpha', '\beta=2\alpha', '\gamma=3\alpha');
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1430 %! set (h, "interpreter", "tex");
11434
1f54ee6760b5 legend.m: Only one legend per axes (bug 32022)
Ben Abbott <bpabbott@mac.com>
parents: 11418
diff changeset
1431
1f54ee6760b5 legend.m: Only one legend per axes (bug 32022)
Ben Abbott <bpabbott@mac.com>
parents: 11418
diff changeset
1432 %!demo
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1433 %! clf;
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1434 %! plot (rand (2));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1435 %! title ("Labels with TeX interpreter turned off");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1436 %! h = legend ("Hello_World", "foo^bar");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1437 %! set (h, "interpreter", "none");
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1438
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1439 %!demo
15442
015cc3d1f389 legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents: 15441
diff changeset
1440 %! clf;
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
1441 %! labels = {};
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1442 %! colororder = get (gca, "colororder");
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
1443 %! for i = 1:5
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14252
diff changeset
1444 %! h = plot (1:100, i + rand (100,1)); hold on;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1445 %! set (h, "color", colororder(i,:));
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1446 %! labels = {labels{:}, ["Signal ", num2str(i)]};
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1447 %! endfor
11363
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 11246
diff changeset
1448 %! hold off;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1449 %! title ({"Signals with random offset and uniform noise";
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1450 %! "Legend shown below and outside of plot"});
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1451 %! xlabel ("Sample Nr [k]"); ylabel ("Amplitude [V]");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1452 %! legend (labels, "location", "southoutside");
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1453
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1454 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1455 %! clf;
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1456 %! x = linspace (0, 10);
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1457 %! plot (x, x);
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1458 %! hold on;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1459 %! stem (x, x.^2, "g");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1460 %! title ("First created object gets first label");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1461 %! legend ("linear");
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1462 %! hold off;
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1463
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1464 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1465 %! clf;
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1466 %! x = linspace (0, 10);
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1467 %! plot (x, x, x, x.^2);
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1468 %! title ("First created object gets first label");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1469 %! legend ("linear");
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1470
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1471 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1472 %! clf;
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1473 %! x = linspace (0, 10);
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1474 %! plot (x, x, x, x.^2);
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1475 %! title ("Labels are applied in order of object creation");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1476 %! legend ("linear", "quadratic");
9457
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
1477
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
1478 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1479 %! clf;
22629
4bd7bab38f39 Add stem example to the hggroup type of legend (bug #49341).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22489
diff changeset
1480 %! subplot (2,1,1);
11363
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 11246
diff changeset
1481 %! rand_2x3_data1 = [0.341447, 0.171220, 0.284370; 0.039773, 0.731725, 0.779382];
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 11246
diff changeset
1482 %! bar (rand_2x3_data1);
13936
bfaacd5e7379 Bug fix (#34901). Allow legend options to be specified. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents: 13279
diff changeset
1483 %! ylim ([0 1.0]);
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1484 %! title ("legend() works for bar graphs (hggroups)");
22629
4bd7bab38f39 Add stem example to the hggroup type of legend (bug #49341).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22489
diff changeset
1485 %! legend ({"1st Bar", "2nd Bar", "3rd Bar"}, "location", "northwest");
4bd7bab38f39 Add stem example to the hggroup type of legend (bug #49341).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22489
diff changeset
1486 %! subplot (2,1,2);
23253
8a1ba13e9914 Correct hggroup plot legends for gnuplot toolkit, add legend demo 17 items (bug #49341)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 23219
diff changeset
1487 %! x = linspace (0, 10, 20);
8a1ba13e9914 Correct hggroup plot legends for gnuplot toolkit, add legend demo 17 items (bug #49341)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 23219
diff changeset
1488 %! stem (x, 0.5+x.*rand (size (x))/max (x), "markeredgecolor", [0 0.7 0]);
8a1ba13e9914 Correct hggroup plot legends for gnuplot toolkit, add legend demo 17 items (bug #49341)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 23219
diff changeset
1489 %! hold on;
8a1ba13e9914 Correct hggroup plot legends for gnuplot toolkit, add legend demo 17 items (bug #49341)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 23219
diff changeset
1490 %! stem (x+10/(2*20), x.*(1.0+rand (size (x)))/max (x));
8a1ba13e9914 Correct hggroup plot legends for gnuplot toolkit, add legend demo 17 items (bug #49341)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 23219
diff changeset
1491 %! xlim ([0 10+10/(2*20)]);
22629
4bd7bab38f39 Add stem example to the hggroup type of legend (bug #49341).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22489
diff changeset
1492 %! title ("legend() works for stem plots (hggroups)");
23253
8a1ba13e9914 Correct hggroup plot legends for gnuplot toolkit, add legend demo 17 items (bug #49341)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 23219
diff changeset
1493 %! legend ({"Multicolor", "Unicolor"}, "location", "northwest");
9457
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
1494
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
1495 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1496 %! clf;
20408
71bd638e0ef6 legend.m: Fix listeners on legend line objects (bug #45563).
Rik <rik@octave.org>
parents: 20286
diff changeset
1497 %! colormap (cool (64));
71bd638e0ef6 legend.m: Fix listeners on legend line objects (bug #45563).
Rik <rik@octave.org>
parents: 20286
diff changeset
1498 %! surf (peaks ());
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1499 %! legend ("peaks()");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1500 %! title ("legend() works for surface objects too");
20408
71bd638e0ef6 legend.m: Fix listeners on legend line objects (bug #45563).
Rik <rik@octave.org>
parents: 20286
diff changeset
1501
71bd638e0ef6 legend.m: Fix listeners on legend line objects (bug #45563).
Rik <rik@octave.org>
parents: 20286
diff changeset
1502 %!demo
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1503 %! clf reset; # needed to undo colormap assignment in previous demo
11363
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 11246
diff changeset
1504 %! rand_2x3_data2 = [0.44804, 0.84368, 0.23012; 0.72311, 0.58335, 0.90531];
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 11246
diff changeset
1505 %! bar (rand_2x3_data2);
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 11246
diff changeset
1506 %! ylim ([0 1.2]);
22151
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22069
diff changeset
1507 %! title ('"left" option places colors to the left of text label');
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1508 %! legend ("1st Bar", "2nd Bar", "3rd Bar");
18888
962db83e36c3 legend.m: Update demo 19 with more descriptive title.
Rik <rik@octave.org>
parents: 18753
diff changeset
1509 %! legend left;
10662
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
1510
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
1511 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1512 %! clf;
10662
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
1513 %! x = 0:0.1:7;
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1514 %! h = plot (x,sin(x), x,cos(x), x,sin(x.^2/10), x,cos(x.^2/10));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1515 %! title ("Only the sin() objects have keylabels");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1516 %! legend (h([1, 3]), {"sin (x)", "sin (x^2/10)"}, "location", "southwest");
11363
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 11246
diff changeset
1517
12340
d63007ac067a legend.m: Add demo for inline keys created by two plot commands.
Ben Abbott <bpabbott@mac.com>
parents: 12339
diff changeset
1518 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1519 %! clf;
12340
d63007ac067a legend.m: Add demo for inline keys created by two plot commands.
Ben Abbott <bpabbott@mac.com>
parents: 12339
diff changeset
1520 %! x = 0:0.1:10;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1521 %! plot (x, sin (x), ";sin (x);");
22069
9121d6584f6a Overhaul graphics implementation of hold() (bug #43559).
Rik <rik@octave.org>
parents: 22054
diff changeset
1522 %! hold on;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1523 %! plot (x, cos (x), ";cos (x);");
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1524 %! hold off;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1525 %! title ("legend constructed from multiple plot calls");
12340
d63007ac067a legend.m: Add demo for inline keys created by two plot commands.
Ben Abbott <bpabbott@mac.com>
parents: 12339
diff changeset
1526
12387
5fb6ea1bff65 legend.m: Add demo for replacing existing legend.
Ben Abbott <bpabbott@mac.com>
parents: 12340
diff changeset
1527 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1528 %! clf;
12387
5fb6ea1bff65 legend.m: Add demo for replacing existing legend.
Ben Abbott <bpabbott@mac.com>
parents: 12340
diff changeset
1529 %! x = 0:0.1:10;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1530 %! plot (x, sin (x), ";sin (x);");
22069
9121d6584f6a Overhaul graphics implementation of hold() (bug #43559).
Rik <rik@octave.org>
parents: 22054
diff changeset
1531 %! hold on;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1532 %! plot (x, cos (x), ";cos (x);");
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1533 %! hold off;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1534 %! title ("Specified label text overrides previous labels");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1535 %! legend ({"Sine", "Cosine"}, "location", "northeastoutside");
12387
5fb6ea1bff65 legend.m: Add demo for replacing existing legend.
Ben Abbott <bpabbott@mac.com>
parents: 12340
diff changeset
1536
12394
c2e1973d870b legend.m: "legend off" should delete the legend object.
Ben Abbott <bpabbott@mac.com>
parents: 12388
diff changeset
1537 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1538 %! clf;
12394
c2e1973d870b legend.m: "legend off" should delete the legend object.
Ben Abbott <bpabbott@mac.com>
parents: 12388
diff changeset
1539 %! x = 0:10;
c2e1973d870b legend.m: "legend off" should delete the legend object.
Ben Abbott <bpabbott@mac.com>
parents: 12388
diff changeset
1540 %! plot (x, rand (11));
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1541 %! axis ([0, 10, 0, 1]);
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1542 %! xlabel ("Indices");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1543 %! ylabel ("Random Values");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1544 %! title ('Legend "off" deletes the legend');
22624
37b7b86f62f2 Fix legend.m typo in demo example 23 (bug #49341).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22489
diff changeset
1545 %! legend (cellstr (num2str ((0:10)')), "location", "northeastoutside");
37b7b86f62f2 Fix legend.m typo in demo example 23 (bug #49341).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22489
diff changeset
1546 %! pause (1);
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1547 %! legend off;
12387
5fb6ea1bff65 legend.m: Add demo for replacing existing legend.
Ben Abbott <bpabbott@mac.com>
parents: 12340
diff changeset
1548
12395
4d30b4136a3e legend.m: Align legends to plot box, add demo. Bug 32373.
Ben Abbott <bpabbott@mac.com>
parents: 12394
diff changeset
1549 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1550 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1551 %! x = (1:5)';
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14252
diff changeset
1552 %! subplot (2,2,1);
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1553 %! plot (x, rand (numel (x)));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1554 %! legend (cellstr (num2str (x)), "location", "northwestoutside");
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14252
diff changeset
1555 %! subplot (2,2,2);
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1556 %! plot (x, rand (numel (x)));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1557 %! legend (cellstr (num2str (x)), "location", "northeastoutside");
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14252
diff changeset
1558 %! subplot (2,2,3);
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1559 %! plot (x, rand (numel (x)));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1560 %! legend (cellstr (num2str (x)), "location", "southwestoutside");
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14252
diff changeset
1561 %! subplot (2,2,4);
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1562 %! plot (x, rand (numel (x)));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1563 %! legend (cellstr (num2str (x)), "location", "southeastoutside");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1564 %! ## Legend works on a per axes basis for each subplot
12387
5fb6ea1bff65 legend.m: Add demo for replacing existing legend.
Ben Abbott <bpabbott@mac.com>
parents: 12340
diff changeset
1565
12395
4d30b4136a3e legend.m: Align legends to plot box, add demo. Bug 32373.
Ben Abbott <bpabbott@mac.com>
parents: 12394
diff changeset
1566 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1567 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14236
diff changeset
1568 %! plot (rand (2));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1569 %! title ("legend() will warn if extra labels are specified");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1570 %! legend ("Hello", "World", "interpreter", "foobar");
13979
f35b593688a5 Changing the legend's interpreter property should be inherited by the
Ben Abbott <bpabbott@mac.com>
parents: 13937
diff changeset
1571
f35b593688a5 Changing the legend's interpreter property should be inherited by the
Ben Abbott <bpabbott@mac.com>
parents: 13937
diff changeset
1572 %!demo
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1573 %! clf;
14207
57e3490094e1 Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
1574 %! x = 0:10;
57e3490094e1 Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
1575 %! y1 = rand (size (x));
57e3490094e1 Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
1576 %! y2 = rand (size (x));
57e3490094e1 Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
1577 %! [ax, h1, h2] = plotyy (x, y1, x, y2);
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1578 %! title ({"plotyy legend test #1", "Blue label to left axis, Orange label to right axis"});
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1579 %! drawnow ();
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1580 %! legend ("Blue", "Orange", "location", "south");
12395
4d30b4136a3e legend.m: Align legends to plot box, add demo. Bug 32373.
Ben Abbott <bpabbott@mac.com>
parents: 12394
diff changeset
1581
13979
f35b593688a5 Changing the legend's interpreter property should be inherited by the
Ben Abbott <bpabbott@mac.com>
parents: 13937
diff changeset
1582 %!demo
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1583 %! clf;
14207
57e3490094e1 Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
1584 %! x = 0:10;
57e3490094e1 Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
1585 %! y1 = rand (size (x));
57e3490094e1 Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
1586 %! y2 = rand (size (x));
57e3490094e1 Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
1587 %! [ax, h1, h2] = plotyy (x, y1, x, y2);
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1588 %! ylabel (ax(1), {"Blue", "Y", "Axis"});
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1589 %! title ('plotyy legend test #2: "westoutside" adjusts to ylabel');
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1590 %! drawnow ();
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1591 %! legend ([h1, h2], {"Blue", "Orange"}, "location", "westoutside");
13979
f35b593688a5 Changing the legend's interpreter property should be inherited by the
Ben Abbott <bpabbott@mac.com>
parents: 13937
diff changeset
1592
f35b593688a5 Changing the legend's interpreter property should be inherited by the
Ben Abbott <bpabbott@mac.com>
parents: 13937
diff changeset
1593 %!demo
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1594 %! clf;
14207
57e3490094e1 Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
1595 %! x = 0:10;
57e3490094e1 Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
1596 %! y1 = rand (size (x));
57e3490094e1 Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
1597 %! y2 = rand (size (x));
57e3490094e1 Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
1598 %! [ax, h1, h2] = plotyy (x, y1, x, y2);
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1599 %! ylabel (ax(2), {"Orange", "Y", "Axis"});
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1600 %! title ('plotyy legend test #3: "eastoutside" adjusts to ylabel');
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1601 %! drawnow ();
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1602 %! legend ([h1, h2], {"Blue", "Orange"}, "location", "eastoutside");
13979
f35b593688a5 Changing the legend's interpreter property should be inherited by the
Ben Abbott <bpabbott@mac.com>
parents: 13937
diff changeset
1603
20408
71bd638e0ef6 legend.m: Fix listeners on legend line objects (bug #45563).
Rik <rik@octave.org>
parents: 20286
diff changeset
1604 %!demo
71bd638e0ef6 legend.m: Fix listeners on legend line objects (bug #45563).
Rik <rik@octave.org>
parents: 20286
diff changeset
1605 %! clf;
71bd638e0ef6 legend.m: Fix listeners on legend line objects (bug #45563).
Rik <rik@octave.org>
parents: 20286
diff changeset
1606 %! plot (1:10, 1:10);
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1607 %! title ("a very long label can sometimes cause problems");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1608 %! legend ("hello very big world", "location", "northeastoutside");
20408
71bd638e0ef6 legend.m: Fix listeners on legend line objects (bug #45563).
Rik <rik@octave.org>
parents: 20286
diff changeset
1609
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1610 %!demo # bug 36408
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1611 %! clf;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1612 %! option = "right";
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
1613 %! subplot (3,1,1);
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1614 %! plot (rand (1,4));
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1615 %! xlabel xlabel;
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1616 %! ylabel ylabel;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1617 %! title ("Subplots adjust to the legend placed outside");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1618 %! legend ({"1"}, "location", "northeastoutside");
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1619 %! legend (option);
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
1620 %! subplot (3,1,2);
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1621 %! plot (rand (1,4));
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1622 %! xlabel xlabel;
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1623 %! ylabel ylabel;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1624 %! legend ({"1234567890"}, "location", "eastoutside");
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1625 %! legend (option);
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
1626 %! subplot (3,1,3);
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1627 %! plot (rand (1,4));
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1628 %! xlabel xlabel;
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1629 %! ylabel ylabel;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1630 %! legend ({"12345678901234567890"}, "location", "southeastoutside");
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1631 %! legend (option);
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1632
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1633 %!demo # bug 36408
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1634 %! clf;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1635 %! option = "right";
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1636 %! subplot (3,1,1);
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1637 %! plot (rand (1,4));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1638 %! title ("Subplots adjust to the legend placed outside");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1639 %! legend ({"1"}, "location", "northwestoutside");
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1640 %! legend (option);
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
1641 %! subplot (3,1,2);
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1642 %! plot (rand (1,4));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1643 %! legend ({"1234567890"}, "location", "westoutside");
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1644 %! legend (option);
16805
2281d957cde6 legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents: 16800
diff changeset
1645 %! subplot (3,1,3);
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1646 %! plot (rand (1,4));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1647 %! legend ({"12345678901234567890"}, "location", "southwestoutside");
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1648 %! legend (option);
16799
286904321282 Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents: 16796
diff changeset
1649
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1650 %!demo # bug 36408
16908
1c4be5dcacd5 Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents: 16885
diff changeset
1651 %! clf;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1652 %! option = "right";
16908
1c4be5dcacd5 Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents: 16885
diff changeset
1653 %! subplot (3,1,1);
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1654 %! plot (rand (1,4));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1655 %! set (gca (), "yaxislocation", "right");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1656 %! xlabel ("xlabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1657 %! ylabel ("ylabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1658 %! title ("Subplots adjust to the legend placed outside");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1659 %! legend ({"1"}, "location", "northeastoutside");
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1660 %! legend (option);
16908
1c4be5dcacd5 Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents: 16885
diff changeset
1661 %! subplot (3,1,2);
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1662 %! plot (rand (1,4));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1663 %! set (gca (), "yaxislocation", "right");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1664 %! xlabel ("xlabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1665 %! ylabel ("ylabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1666 %! legend ({"1234567890"}, "location", "eastoutside");
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1667 %! legend (option);
16908
1c4be5dcacd5 Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents: 16885
diff changeset
1668 %! subplot (3,1,3);
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1669 %! plot (rand (1,4));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1670 %! set (gca (), "yaxislocation", "right");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1671 %! xlabel ("xlabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1672 %! ylabel ("ylabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1673 %! legend ({"12345678901234567890"}, "location", "southeastoutside");
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1674 %! legend (option);
16908
1c4be5dcacd5 Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents: 16885
diff changeset
1675
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1676 %!demo # bug 36408
16908
1c4be5dcacd5 Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents: 16885
diff changeset
1677 %! clf;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1678 %! option = "right";
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1679 %! subplot (3,1,1);
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1680 %! plot (rand (1,4));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1681 %! set (gca (), "yaxislocation", "right");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1682 %! xlabel ("xlabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1683 %! ylabel ("ylabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1684 %! title ("Subplots adjust to the legend placed outside");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1685 %! legend ({"1"}, "location", "northwestoutside");
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1686 %! legend (option);
16908
1c4be5dcacd5 Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents: 16885
diff changeset
1687 %! subplot (3,1,2);
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1688 %! plot (rand (1,4));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1689 %! set (gca (), "yaxislocation", "right");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1690 %! xlabel ("xlabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1691 %! ylabel ("ylabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1692 %! legend ({"1234567890"}, "location", "westoutside");
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1693 %! legend (option);
16908
1c4be5dcacd5 Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents: 16885
diff changeset
1694 %! subplot (3,1,3);
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1695 %! plot (rand (1,4));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1696 %! set (gca (), "yaxislocation", "right");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1697 %! xlabel ("xlabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1698 %! ylabel ("ylabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1699 %! legend ({"12345678901234567890"}, "location", "southwestoutside");
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1700 %! legend (option);
16908
1c4be5dcacd5 Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents: 16885
diff changeset
1701
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1702 %!demo # bug 36408;
16908
1c4be5dcacd5 Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents: 16885
diff changeset
1703 %! clf;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1704 %! option = "right";
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1705 %! subplot (3,1,1);
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1706 %! plot (rand (1,4));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1707 %! set (gca (), "xaxislocation", "top");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1708 %! xlabel ("xlabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1709 %! ylabel ("ylabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1710 %! title ("Subplots adjust to the legend placed outside");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1711 %! legend ({"1"}, "location", "northwestoutside");
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1712 %! legend (option);
16908
1c4be5dcacd5 Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents: 16885
diff changeset
1713 %! subplot (3,1,2);
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1714 %! plot (rand (1,4));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1715 %! set (gca (), "xaxislocation", "top");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1716 %! xlabel ("xlabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1717 %! ylabel ("ylabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1718 %! legend ({"1234567890"}, "location", "westoutside");
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1719 %! legend (option);
16908
1c4be5dcacd5 Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents: 16885
diff changeset
1720 %! subplot (3,1,3);
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1721 %! plot (rand (1,4));
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1722 %! set (gca (), "xaxislocation", "top");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1723 %! xlabel ("xlabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1724 %! ylabel ("ylabel");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1725 %! legend ({"12345678901234567890"}, "location", "southwestoutside");
16921
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1726 %! legend (option);
9a316ec12b5f legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents: 16910
diff changeset
1727
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1728 %!demo # bug 39697
17190
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17179
diff changeset
1729 %! clf;
17179
828e8852efa9 legend.m: Add %!demo block showing bug #39697.
Rik <rik@octave.org>
parents: 17174
diff changeset
1730 %! plot (1:10);
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1731 %! legend ("Legend Text");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22151
diff changeset
1732 %! title ({"Multi-line", "titles", "are a", "problem", "See bug #39697"});
17179
828e8852efa9 legend.m: Add %!demo block showing bug #39697.
Rik <rik@octave.org>
parents: 17174
diff changeset
1733
23508
4b38c9687331 Skip tests that require gnuplot when gnuplot is not installed (bug #36983)
Mike Miller <mtmiller@octave.org>
parents: 23263
diff changeset
1734 %!testif ; any (strcmp ("gnuplot", available_graphics_toolkits ()))
17107
dbd64c9a16da Restore graphics toolkit after %!tests that alter it.
Rik <rik@octave.org>
parents: 17065
diff changeset
1735 %! toolkit = graphics_toolkit ("gnuplot");
17119
bd50e0660545 test: Add missing semicolons to suppress output in some plot %!tests.
Rik <rik@octave.org>
parents: 17107
diff changeset
1736 %! h = figure ("visible", "off");
16973
d429a05dc11c legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents: 16933
diff changeset
1737 %! unwind_protect
d429a05dc11c legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents: 16933
diff changeset
1738 %! position = get (h, "position");
d429a05dc11c legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents: 16933
diff changeset
1739 %! plot (rand (3));
d429a05dc11c legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents: 16933
diff changeset
1740 %! legend ();
19278
6ca096827123 Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents: 18937
diff changeset
1741 %! filename = sprintf ("%s.eps", tempname ());
16973
d429a05dc11c legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents: 16933
diff changeset
1742 %! print (filename);
d429a05dc11c legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents: 16933
diff changeset
1743 %! unlink (filename);
d429a05dc11c legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents: 16933
diff changeset
1744 %! assert (get (h, "position"), position);
d429a05dc11c legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents: 16933
diff changeset
1745 %! unwind_protect_cleanup
d429a05dc11c legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents: 16933
diff changeset
1746 %! close (h);
17107
dbd64c9a16da Restore graphics toolkit after %!tests that alter it.
Rik <rik@octave.org>
parents: 17065
diff changeset
1747 %! graphics_toolkit (toolkit);
16973
d429a05dc11c legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents: 16933
diff changeset
1748 %! end_unwind_protect
d429a05dc11c legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents: 16933
diff changeset
1749
23573
1b4f4ec53b4a use new script to tag fixed bugs in tests
John W. Eaton <jwe@octave.org>
parents: 23572
diff changeset
1750 %!test <*42035>
18647
ce36233e4849 legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents: 18644
diff changeset
1751 %! h = figure ("visible", "off");
ce36233e4849 legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents: 18644
diff changeset
1752 %! unwind_protect
ce36233e4849 legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents: 18644
diff changeset
1753 %! hax1 = subplot (1,2,1);
ce36233e4849 legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents: 18644
diff changeset
1754 %! plot (1:10);
ce36233e4849 legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents: 18644
diff changeset
1755 %! hax2 = subplot (1,2,2);
ce36233e4849 legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents: 18644
diff changeset
1756 %! plot (1:10);
ce36233e4849 legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents: 18644
diff changeset
1757 %! hleg1 = legend (hax1, "foo");
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
1758 %! assert (getappdata (hleg1, "__axes_handle__"), hax1);
18647
ce36233e4849 legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents: 18644
diff changeset
1759 %! assert (gca (), hax2);
ce36233e4849 legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents: 18644
diff changeset
1760 %! hleg2 = legend ("bar");
24498
5865d2fef424 legend.m: Clean up implementation.
Rik <rik@octave.org>
parents: 24482
diff changeset
1761 %! assert (getappdata (hleg2, "__axes_handle__"), gca ());
18647
ce36233e4849 legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents: 18644
diff changeset
1762 %! unwind_protect_cleanup
ce36233e4849 legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents: 18644
diff changeset
1763 %! close (h);
ce36233e4849 legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents: 18644
diff changeset
1764 %! end_unwind_protect
24434
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1765
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1766 %!test
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1767 %! ## Difficult example from plotyy demo #1
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1768 %! hf = figure ("visible", "off");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1769 %! unwind_protect
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1770 %! x = 0:0.1:2*pi;
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1771 %! y1 = sin (x);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1772 %! y2 = exp (x - 1);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1773 %! hax = plotyy (x,y1, x-1,y2, @plot, @semilogy);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1774 %! text (0.5, 0.5, "Left Axis", "parent", hax(1));
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1775 %! text (4.5, 80, "Right Axis", "parent", hax(2));
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1776 %! hleg = legend ("show");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1777 %! assert (get (hleg, "string"), {"data1", "data2"});
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1778 %! fail ("legend ('foo', 'bar', 'baz')", "warning", "ignoring extra labels");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1779 %! unwind_protect_cleanup
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1780 %! close (hf);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1781 %! end_unwind_protect
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1782
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1783 %!test
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1784 %! ## Test warnings about objects to label
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1785 %! hf = figure ("visible", "off");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1786 %! unwind_protect
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1787 %! hax = gca ();
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1788 %! fail ("legend ('foobar')", "warning", "plot data is empty");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1789 %! ht = text (0.5, 0.5, "Hello World");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1790 %! fail ("legend ('foobar')", "warning", "plot data is empty");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1791 %! lastwarn (""); # clear warning
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1792 %! hleg = legend ();
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1793 %! assert (isempty (hleg) && isempty (lastwarn ()));
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1794 %! fail ("legend ('foobar')", "warning", "plot data is empty");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1795 %! hln = line ([0 1], [0 1]);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1796 %! fail ("legend ('foo', 'bar')", "warning", "ignoring extra labels");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1797 %! plot (rand (2, 21));
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1798 %! fail ("legend ()", "warning", "labeling only first 20 data objects");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1799 %! unwind_protect_cleanup
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1800 %! close (hf);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1801 %! end_unwind_protect
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1802
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1803 %!test
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1804 %! ## Test warnings about unsupported features
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1805 %! hf = figure ("visible", "off");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1806 %! unwind_protect
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1807 %! plot (1:10);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1808 %! fail ("legend ('location','best')", "warning", "'best' not yet implemented");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1809 %! fail ("legend ('location','bestoutside')", "warning", "'best' not yet implemented");
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1810 %! unwind_protect_cleanup
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1811 %! close (hf);
436deae9f9ab legend.m: Overhaul function for greater Matlab compatibility.
Rik <rik@octave.org>
parents: 24432
diff changeset
1812 %! end_unwind_protect