├── repository ├── .gitignore ├── .project ├── src ├── .properties ├── MatplotLibBridge │ ├── package.st │ ├── Color.extension.st │ ├── ManifestMatplotLibBridge.class.st │ ├── MLBXAxis.class.st │ ├── MLBYAxis.class.st │ ├── MLBXKCDStyleSheet.class.st │ ├── P3GCall.extension.st │ ├── MLBGridStyle.class.st │ ├── MLBScaleStyle.class.st │ ├── MLBVisitableObject.class.st │ ├── MLBLineStyle.class.st │ ├── MLBArrowStyle.class.st │ ├── String.extension.st │ ├── MLBMarkerStyle.class.st │ ├── MLBYBlockLine.class.st │ ├── MLBXBlockLine.class.st │ ├── MLBConfigurationUnfinished.class.st │ ├── MLBStyleSheet.class.st │ ├── MLBStyleSheetProperty.class.st │ ├── MLBScatterPlot2.class.st │ ├── MLBScatterPlot.class.st │ ├── MLBCircle.class.st │ ├── MLBBarPlot.class.st │ ├── MLBStackedBarPlot.class.st │ ├── MLBPointsLine.class.st │ ├── MLBBoxPlot.class.st │ ├── MLBStyle.class.st │ ├── MLBLegend.class.st │ ├── MLBScatterData.class.st │ ├── MLBAnnotation.class.st │ ├── MLBAbstractBarPlot.class.st │ ├── MLBPiePlot.class.st │ ├── MLBAbstractAxis.class.st │ ├── MLBLine.class.st │ ├── MLBLinePlot.class.st │ ├── MLBAbstractVisitor.class.st │ ├── MLBAbstractPlot.class.st │ └── MLBExamples.class.st ├── MatplotLibBridge-Atlas │ ├── package.st │ ├── P3GInterpreter.extension.st │ └── MLBAtlasInterpreter.class.st ├── MatplotLibBridge-Tests │ └── package.st ├── BaselineOfMatplotLibBridge │ ├── package.st │ └── BaselineOfMatplotLibBridge.class.st └── MatplotLibBridge-Commands │ ├── package.st │ ├── MLBTwinX.class.st │ ├── MLBTwinY.class.st │ ├── MLBClfCommand.class.st │ ├── MLBShowCommand.class.st │ ├── MLBRcDefaultsCommand.class.st │ ├── MLBAxis.class.st │ ├── MLBXLabelCommand.class.st │ ├── MLBYLabelCommand.class.st │ ├── MLBXScaleCommand.class.st │ ├── MLBYScaleCommand.class.st │ ├── MLBGridCommand.class.st │ ├── MLBPyplotCommand.class.st │ ├── MLBMatplotlibCommand.class.st │ ├── MLBXLimCommand.class.st │ ├── MLBYLimCommand.class.st │ ├── MLBRcCommand.class.st │ ├── MLBTitleCommand.class.st │ ├── MLBAbstractPlot.extension.st │ ├── MLBXTicksCommand.class.st │ ├── MLBYTicksCommand.class.st │ ├── MLBXkcdCommand.class.st │ ├── MLBFigureCommand.class.st │ ├── MLBCommand.class.st │ ├── MLBCommandList.class.st │ ├── MLBScatterCommand.class.st │ ├── MLBSaveFigCommand.class.st │ ├── MLBAnnotateCommand.class.st │ ├── MLBBarCommand.class.st │ ├── MLBPieCommand.class.st │ ├── MLBBoxplotCommand.class.st │ ├── MLBPlotCommand.class.st │ ├── MLBCommandListGenerator.class.st │ └── MLBLegendCommand.class.st ├── plots ├── exampleBarplot.png ├── exampleLegend.png ├── examplePieplot.png ├── exampleLineplot.png ├── exampleStyleSheet.png ├── exampleAnnotations.png ├── exampleScatterplot.png ├── exampleScatterplot2.png ├── exampleMultilineplot.png ├── exampleStackedBarplot.png ├── exampleVerticalBoxplot.png ├── exampleHorizontalBoxplot.png ├── exampleLogscaleLineplot.png ├── exampleLineplotYBlockLine.png ├── exampleDiscontinuousLineplot.png └── exampleChangingLineWidthOfLineplot.png ├── .smalltalk.ston ├── .travis.yml ├── LICENSE └── README.md /repository: -------------------------------------------------------------------------------- 1 | ./src -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | { 2 | 'srcDirectory' : 'src' 3 | } 4 | -------------------------------------------------------------------------------- /src/.properties: -------------------------------------------------------------------------------- 1 | { 2 | #format : #tonel 3 | }e 4 | } -------------------------------------------------------------------------------- /src/MatplotLibBridge/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #MatplotLibBridge } 2 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Atlas/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #'MatplotLibBridge-Atlas' } 2 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Tests/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #'MatplotLibBridge-Tests' } 2 | -------------------------------------------------------------------------------- /src/BaselineOfMatplotLibBridge/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #BaselineOfMatplotLibBridge } 2 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #'MatplotLibBridge-Commands' } 2 | -------------------------------------------------------------------------------- /plots/exampleBarplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/exampleBarplot.png -------------------------------------------------------------------------------- /plots/exampleLegend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/exampleLegend.png -------------------------------------------------------------------------------- /plots/examplePieplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/examplePieplot.png -------------------------------------------------------------------------------- /plots/exampleLineplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/exampleLineplot.png -------------------------------------------------------------------------------- /plots/exampleStyleSheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/exampleStyleSheet.png -------------------------------------------------------------------------------- /plots/exampleAnnotations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/exampleAnnotations.png -------------------------------------------------------------------------------- /plots/exampleScatterplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/exampleScatterplot.png -------------------------------------------------------------------------------- /plots/exampleScatterplot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/exampleScatterplot2.png -------------------------------------------------------------------------------- /plots/exampleMultilineplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/exampleMultilineplot.png -------------------------------------------------------------------------------- /plots/exampleStackedBarplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/exampleStackedBarplot.png -------------------------------------------------------------------------------- /plots/exampleVerticalBoxplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/exampleVerticalBoxplot.png -------------------------------------------------------------------------------- /plots/exampleHorizontalBoxplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/exampleHorizontalBoxplot.png -------------------------------------------------------------------------------- /plots/exampleLogscaleLineplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/exampleLogscaleLineplot.png -------------------------------------------------------------------------------- /plots/exampleLineplotYBlockLine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/exampleLineplotYBlockLine.png -------------------------------------------------------------------------------- /plots/exampleDiscontinuousLineplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/exampleDiscontinuousLineplot.png -------------------------------------------------------------------------------- /plots/exampleChangingLineWidthOfLineplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/HEAD/plots/exampleChangingLineWidthOfLineplot.png -------------------------------------------------------------------------------- /src/MatplotLibBridge-Atlas/P3GInterpreter.extension.st: -------------------------------------------------------------------------------- 1 | Extension { #name : #P3GInterpreter } 2 | 3 | { #category : #'*MatplotLibBridge-Atlas' } 4 | P3GInterpreter class >> useAtlasInterpreter [ 5 | self current: MLBAtlasInterpreter 6 | ] 7 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/Color.extension.st: -------------------------------------------------------------------------------- 1 | Extension { #name : #Color } 2 | 3 | { #category : #'*MatplotLibBridge' } 4 | Color >> writePython3On: aStream [ 5 | aStream 6 | << '''#'; 7 | << self asHexString; 8 | << '''' 9 | ] 10 | -------------------------------------------------------------------------------- /.smalltalk.ston: -------------------------------------------------------------------------------- 1 | SmalltalkCISpec { 2 | #loading : [ 3 | SCIMetacelloLoadSpec { 4 | #baseline : 'MatplotLibBridge', 5 | #directory : 'src', 6 | #platforms : [ #pharo ] 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBTwinX.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #MLBTwinX, 3 | #superclass : #MLBPyplotCommand, 4 | #category : #'MatplotLibBridge-Commands-Core' 5 | } 6 | 7 | { #category : #accessing } 8 | MLBTwinX >> functionName [ 9 | ^ 'twinx' 10 | ] 11 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBTwinY.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #MLBTwinY, 3 | #superclass : #MLBPyplotCommand, 4 | #category : #'MatplotLibBridge-Commands-Core' 5 | } 6 | 7 | { #category : #accessing } 8 | MLBTwinY >> functionName [ 9 | ^ 'twiny' 10 | ] 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: smalltalk 2 | sudo: false 3 | notifications: 4 | email: 5 | on_success: never 6 | on_failure: always 7 | os: 8 | - linux 9 | - osx 10 | 11 | smalltalk: 12 | - Pharo-6.1 13 | - Pharo-7.0 14 | - Pharo32-8.0 15 | - Pharo64-8.0 16 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/ManifestMatplotLibBridge.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser 3 | " 4 | Class { 5 | #name : #ManifestMatplotLibBridge, 6 | #superclass : #PackageManifest, 7 | #category : #'MatplotLibBridge-Manifest' 8 | } 9 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBXAxis.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am the description of an X axis of a plot. 3 | " 4 | Class { 5 | #name : #MLBXAxis, 6 | #superclass : #MLBAbstractAxis, 7 | #category : #'MatplotLibBridge-Model' 8 | } 9 | 10 | { #category : #visiting } 11 | MLBXAxis >> acceptVisitor: visitor [ 12 | ^ visitor visitMLBXAxis: self 13 | ] 14 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBYAxis.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am the description of an Y axis of a plot. 3 | " 4 | Class { 5 | #name : #MLBYAxis, 6 | #superclass : #MLBAbstractAxis, 7 | #category : #'MatplotLibBridge-Model' 8 | } 9 | 10 | { #category : #visiting } 11 | MLBYAxis >> acceptVisitor: visitor [ 12 | ^ visitor visitMLBYAxis: self 13 | ] 14 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBClfCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.clf function. 3 | " 4 | Class { 5 | #name : #MLBClfCommand, 6 | #superclass : #MLBPyplotCommand, 7 | #category : #'MatplotLibBridge-Commands-Core' 8 | } 9 | 10 | { #category : #accessing } 11 | MLBClfCommand >> functionName [ 12 | ^ 'clf' 13 | ] 14 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBShowCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.show function. 3 | " 4 | Class { 5 | #name : #MLBShowCommand, 6 | #superclass : #MLBPyplotCommand, 7 | #category : #'MatplotLibBridge-Commands-Core' 8 | } 9 | 10 | { #category : #accessing } 11 | MLBShowCommand >> functionName [ 12 | ^ 'show' 13 | ] 14 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBXKCDStyleSheet.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am pre-defined style-sheet showing your plot in XKDC style. 3 | " 4 | Class { 5 | #name : #MLBXKCDStyleSheet, 6 | #superclass : #MLBStyleSheet, 7 | #category : #'MatplotLibBridge-Model' 8 | } 9 | 10 | { #category : #visiting } 11 | MLBXKCDStyleSheet >> acceptVisitor: visitor [ 12 | ^ visitor visitMLBXKCDStyleSheet: self 13 | ] 14 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/P3GCall.extension.st: -------------------------------------------------------------------------------- 1 | Extension { #name : #P3GCall } 2 | 3 | { #category : #'*MatplotLibBridge' } 4 | P3GCall >> executeAndStoreIn: aMLBRemoteVariable [ 5 | | assignment | 6 | assignment := P3GAssignment new 7 | target: aMLBRemoteVariable; 8 | toAssignate: self; 9 | yourself. 10 | P3GInterpreter current 11 | executePythonCode: assignment generate. 12 | ^ aMLBRemoteVariable 13 | ] 14 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBRcDefaultsCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.rcdefaults. 3 | 4 | Restore the standard matplotlib default settings. 5 | " 6 | Class { 7 | #name : #MLBRcDefaultsCommand, 8 | #superclass : #MLBMatplotlibCommand, 9 | #category : #'MatplotLibBridge-Commands-Core' 10 | } 11 | 12 | { #category : #accessing } 13 | MLBRcDefaultsCommand >> functionName [ 14 | ^ 'rcdefaults' 15 | ] 16 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBGridStyle.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I model the style of grid to be used in a plot. 3 | " 4 | Class { 5 | #name : #MLBGridStyle, 6 | #superclass : #MLBStyle, 7 | #category : #'MatplotLibBridge-Core' 8 | } 9 | 10 | { #category : #accessing } 11 | MLBGridStyle class >> validStyleStrings [ 12 | ^ #('both' 'x' 'y') 13 | ] 14 | 15 | { #category : #converting } 16 | MLBGridStyle >> asMLBGridStyle [ 17 | ^ self 18 | ] 19 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBScaleStyle.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I model the style of scale to be used in a plot. 3 | " 4 | Class { 5 | #name : #MLBScaleStyle, 6 | #superclass : #MLBStyle, 7 | #category : #'MatplotLibBridge-Core' 8 | } 9 | 10 | { #category : #accessing } 11 | MLBScaleStyle class >> validStyleStrings [ 12 | ^ #('linear' 'log' 'logit' 'symlog') 13 | ] 14 | 15 | { #category : #converting } 16 | MLBScaleStyle >> asMLBScaleStyle [ 17 | ^ self 18 | ] 19 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBVisitableObject.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am an abstract object which can be visited by a MLBAbstractVisitor. 3 | 4 | I ensure my subclasses implement a sufficient API to be visited. 5 | " 6 | Class { 7 | #name : #MLBVisitableObject, 8 | #superclass : #Object, 9 | #category : #'MatplotLibBridge-Model' 10 | } 11 | 12 | { #category : #visiting } 13 | MLBVisitableObject >> acceptVisitor: visitor [ 14 | ^ self subclassResponsibility 15 | ] 16 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBLineStyle.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I model the style of a line to be used in a plot. 3 | " 4 | Class { 5 | #name : #MLBLineStyle, 6 | #superclass : #MLBStyle, 7 | #category : #'MatplotLibBridge-Core' 8 | } 9 | 10 | { #category : #accessing } 11 | MLBLineStyle class >> validStyleStrings [ 12 | ^ #('solid' 'dashed' 'dashdot' 'dotted' '-' '--' '-.' ':' 'None' ' ' '') 13 | ] 14 | 15 | { #category : #converting } 16 | MLBLineStyle >> asMLBLineStyle [ 17 | ^ self 18 | ] 19 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBAxis.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.axis function. 3 | " 4 | Class { 5 | #name : #MLBAxis, 6 | #superclass : #MLBPyplotCommand, 7 | #instVars : [ 8 | 'v' 9 | ], 10 | #category : #'MatplotLibBridge-Commands-Core' 11 | } 12 | 13 | { #category : #accessing } 14 | MLBAxis >> functionName [ 15 | ^ 'axis' 16 | ] 17 | 18 | { #category : #accessing } 19 | MLBAxis >> v [ 20 | 21 | ^ v 22 | ] 23 | 24 | { #category : #accessing } 25 | MLBAxis >> v: anObject [ 26 | v := anObject 27 | ] 28 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBArrowStyle.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I model the style of an arrow to be used as annotation in a plot. 3 | " 4 | Class { 5 | #name : #MLBArrowStyle, 6 | #superclass : #MLBStyle, 7 | #category : #'MatplotLibBridge-Core' 8 | } 9 | 10 | { #category : #accessing } 11 | MLBArrowStyle class >> validStyleStrings [ 12 | "The allowed values of 'arrowstyle' are:" 13 | ^ #('-' '->' '-[' '|-|' '-|>' '<-' '<->' '<|-' '<|-|>' 'fancy' 'simple' 'wedge') 14 | ] 15 | 16 | { #category : #converting } 17 | MLBArrowStyle >> asMLBArrowStyle [ 18 | ^ self 19 | ] 20 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Atlas/MLBAtlasInterpreter.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I ensure communication with Python using Atlas and provide a slightly higher level than pure Atlas use. 3 | " 4 | Class { 5 | #name : #MLBAtlasInterpreter, 6 | #superclass : #P3GInterpreter, 7 | #category : 'MatplotLibBridge-Atlas' 8 | } 9 | 10 | { #category : #python } 11 | MLBAtlasInterpreter >> executePythonCode: aString [ 12 | Atlas sendMessage: aString 13 | ] 14 | 15 | { #category : #python } 16 | MLBAtlasInterpreter >> executePythonCodeAngGetValue: aString [ 17 | ^ Atlas getValue: aString 18 | ] 19 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBXLabelCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.xlabel function. 3 | " 4 | Class { 5 | #name : #MLBXLabelCommand, 6 | #superclass : #MLBPyplotCommand, 7 | #instVars : [ 8 | 's' 9 | ], 10 | #category : #'MatplotLibBridge-Commands-Core' 11 | } 12 | 13 | { #category : #accessing } 14 | MLBXLabelCommand >> functionName [ 15 | ^ 'xlabel' 16 | ] 17 | 18 | { #category : #accessing } 19 | MLBXLabelCommand >> s [ 20 | 21 | ^ s 22 | ] 23 | 24 | { #category : #accessing } 25 | MLBXLabelCommand >> s: anObject [ 26 | s := anObject 27 | ] 28 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBYLabelCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.ylabel function. 3 | " 4 | Class { 5 | #name : #MLBYLabelCommand, 6 | #superclass : #MLBPyplotCommand, 7 | #instVars : [ 8 | 's' 9 | ], 10 | #category : #'MatplotLibBridge-Commands-Core' 11 | } 12 | 13 | { #category : #accessing } 14 | MLBYLabelCommand >> functionName [ 15 | ^ 'ylabel' 16 | ] 17 | 18 | { #category : #accessing } 19 | MLBYLabelCommand >> s [ 20 | 21 | ^ s 22 | ] 23 | 24 | { #category : #accessing } 25 | MLBYLabelCommand >> s: anObject [ 26 | s := anObject 27 | ] 28 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBXScaleCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.xscale function. 3 | " 4 | Class { 5 | #name : #MLBXScaleCommand, 6 | #superclass : #MLBPyplotCommand, 7 | #instVars : [ 8 | 'scale' 9 | ], 10 | #category : #'MatplotLibBridge-Commands-Core' 11 | } 12 | 13 | { #category : #accessing } 14 | MLBXScaleCommand >> functionName [ 15 | ^ 'xscale' 16 | ] 17 | 18 | { #category : #accessing } 19 | MLBXScaleCommand >> scale [ 20 | 21 | ^ scale 22 | ] 23 | 24 | { #category : #accessing } 25 | MLBXScaleCommand >> scale: anObject [ 26 | scale := anObject 27 | ] 28 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBYScaleCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.yscale function. 3 | " 4 | Class { 5 | #name : #MLBYScaleCommand, 6 | #superclass : #MLBPyplotCommand, 7 | #instVars : [ 8 | 'scale' 9 | ], 10 | #category : #'MatplotLibBridge-Commands-Core' 11 | } 12 | 13 | { #category : #accessing } 14 | MLBYScaleCommand >> functionName [ 15 | ^ 'yscale' 16 | ] 17 | 18 | { #category : #accessing } 19 | MLBYScaleCommand >> scale [ 20 | 21 | ^ scale 22 | ] 23 | 24 | { #category : #accessing } 25 | MLBYScaleCommand >> scale: anObject [ 26 | scale := anObject 27 | ] 28 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBGridCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.legend function. 3 | 4 | My implementation is not complete yet. 5 | " 6 | Class { 7 | #name : #MLBGridCommand, 8 | #superclass : #MLBPyplotCommand, 9 | #instVars : [ 10 | 'axis' 11 | ], 12 | #category : #'MatplotLibBridge-Commands-Core' 13 | } 14 | 15 | { #category : #accessing } 16 | MLBGridCommand >> axis [ 17 | 18 | ^ axis 19 | ] 20 | 21 | { #category : #accessing } 22 | MLBGridCommand >> axis: anObject [ 23 | axis := anObject 24 | ] 25 | 26 | { #category : #accessing } 27 | MLBGridCommand >> functionName [ 28 | ^ 'grid' 29 | ] 30 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBPyplotCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a command using a function from the matplotlib.pyplot Python module. 3 | " 4 | Class { 5 | #name : #MLBPyplotCommand, 6 | #superclass : #MLBCommand, 7 | #category : #'MatplotLibBridge-Commands-Core' 8 | } 9 | 10 | { #category : #accessing } 11 | MLBPyplotCommand class >> pyplotModuleName [ 12 | ^ 'matplotlib' asP3GIdentifier => 'pyplot' 13 | ] 14 | 15 | { #category : #initialization } 16 | MLBPyplotCommand >> initialize [ 17 | super initialize. 18 | self module: self pyplotModuleName 19 | ] 20 | 21 | { #category : #accessing } 22 | MLBPyplotCommand >> pyplotModuleName [ 23 | ^ self class pyplotModuleName 24 | ] 25 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/String.extension.st: -------------------------------------------------------------------------------- 1 | Extension { #name : #String } 2 | 3 | { #category : #'*MatplotLibBridge' } 4 | String >> asMLBArrowStyle [ 5 | ^ MLBArrowStyle styleString: self 6 | ] 7 | 8 | { #category : #'*MatplotLibBridge' } 9 | String >> asMLBGridStyle [ 10 | ^ MLBGridStyle styleString: self 11 | ] 12 | 13 | { #category : #'*MatplotLibBridge' } 14 | String >> asMLBLineStyle [ 15 | ^ MLBLineStyle styleString: self 16 | ] 17 | 18 | { #category : #'*MatplotLibBridge' } 19 | String >> asMLBMarkerStyle [ 20 | ^ MLBMarkerStyle styleString: self 21 | ] 22 | 23 | { #category : #'*MatplotLibBridge' } 24 | String >> asMLBScaleStyle [ 25 | ^ MLBScaleStyle styleString: self 26 | ] 27 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBMatplotlibCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a command using a function from the matplotlib Python module. 3 | " 4 | Class { 5 | #name : #MLBMatplotlibCommand, 6 | #superclass : #MLBCommand, 7 | #category : #'MatplotLibBridge-Commands-Core' 8 | } 9 | 10 | { #category : #accessing } 11 | MLBMatplotlibCommand class >> matplotlibModuleName [ 12 | ^ 'matplotlib' asP3GIdentifier 13 | ] 14 | 15 | { #category : #initialization } 16 | MLBMatplotlibCommand >> initialize [ 17 | super initialize. 18 | self module: self matplotlibModuleName 19 | ] 20 | 21 | { #category : #accessing } 22 | MLBMatplotlibCommand >> matplotlibModuleName [ 23 | ^ self class matplotlibModuleName 24 | ] 25 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBMarkerStyle.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I model the style of a marker to be used in a plot. 3 | " 4 | Class { 5 | #name : #MLBMarkerStyle, 6 | #superclass : #MLBStyle, 7 | #category : #'MatplotLibBridge-Core' 8 | } 9 | 10 | { #category : #testing } 11 | MLBMarkerStyle class >> isValidStyleString: aString [ 12 | ^ (super isValidStyleString: aString) 13 | or: [ aString matchesRegex: '\$.+\$' ] 14 | ] 15 | 16 | { #category : #accessing } 17 | MLBMarkerStyle class >> validStyleStrings [ 18 | ^ #('.' ',' 'o' 'v' '^' '<' '>' '1' '2' '3' '4' '8' 's' 'p' '*' 'h' 'H' '+' 'x' 'D' 'd' '|' '_' 'None' ' ' '') 19 | ] 20 | 21 | { #category : #converting } 22 | MLBMarkerStyle >> asMLBMarkerStyle [ 23 | ^ self 24 | ] 25 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBXLimCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.xlim function. 3 | " 4 | Class { 5 | #name : #MLBXLimCommand, 6 | #superclass : #MLBPyplotCommand, 7 | #instVars : [ 8 | 'xmin', 9 | 'xmax' 10 | ], 11 | #category : #'MatplotLibBridge-Commands-Core' 12 | } 13 | 14 | { #category : #accessing } 15 | MLBXLimCommand >> functionName [ 16 | ^ 'xlim' 17 | ] 18 | 19 | { #category : #accessing } 20 | MLBXLimCommand >> xmax [ 21 | 22 | ^ xmax 23 | ] 24 | 25 | { #category : #accessing } 26 | MLBXLimCommand >> xmax: anObject [ 27 | xmax := anObject 28 | ] 29 | 30 | { #category : #accessing } 31 | MLBXLimCommand >> xmin [ 32 | 33 | ^ xmin 34 | ] 35 | 36 | { #category : #accessing } 37 | MLBXLimCommand >> xmin: anObject [ 38 | xmin := anObject 39 | ] 40 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBYLimCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.ylim function. 3 | " 4 | Class { 5 | #name : #MLBYLimCommand, 6 | #superclass : #MLBPyplotCommand, 7 | #instVars : [ 8 | 'ymin', 9 | 'ymax' 10 | ], 11 | #category : #'MatplotLibBridge-Commands-Core' 12 | } 13 | 14 | { #category : #accessing } 15 | MLBYLimCommand >> functionName [ 16 | ^ 'ylim' 17 | ] 18 | 19 | { #category : #accessing } 20 | MLBYLimCommand >> ymax [ 21 | 22 | ^ ymax 23 | ] 24 | 25 | { #category : #accessing } 26 | MLBYLimCommand >> ymax: anObject [ 27 | ymax := anObject 28 | ] 29 | 30 | { #category : #accessing } 31 | MLBYLimCommand >> ymin [ 32 | 33 | ^ ymin 34 | ] 35 | 36 | { #category : #accessing } 37 | MLBYLimCommand >> ymin: anObject [ 38 | ymin := anObject 39 | ] 40 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBYBlockLine.class.st: -------------------------------------------------------------------------------- 1 | " 2 | A line defined by its x values and a block to generate y-values from x-values. 3 | " 4 | Class { 5 | #name : #MLBYBlockLine, 6 | #superclass : #MLBLine, 7 | #instVars : [ 8 | 'x', 9 | 'yBlock' 10 | ], 11 | #category : #'MatplotLibBridge-Model' 12 | } 13 | 14 | { #category : #visiting } 15 | MLBYBlockLine >> acceptVisitor: visitor [ 16 | ^ visitor visitMLBYBlockLine: self 17 | ] 18 | 19 | { #category : #private } 20 | MLBYBlockLine >> x [ 21 | ^ x 22 | ] 23 | 24 | { #category : #accessing } 25 | MLBYBlockLine >> x: aSequenceableCollection [ 26 | x := aSequenceableCollection 27 | ] 28 | 29 | { #category : #private } 30 | MLBYBlockLine >> y [ 31 | ^ self x collect: [ :data | self yBlock value: data ] 32 | ] 33 | 34 | { #category : #accessing } 35 | MLBYBlockLine >> yBlock [ 36 | ^ yBlock 37 | ] 38 | 39 | { #category : #accessing } 40 | MLBYBlockLine >> yBlock: aBlock [ 41 | yBlock := aBlock 42 | ] 43 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBXBlockLine.class.st: -------------------------------------------------------------------------------- 1 | " 2 | A line defined by its y values and a block to generate x-values from y-values. 3 | " 4 | Class { 5 | #name : #MLBXBlockLine, 6 | #superclass : #MLBLine, 7 | #instVars : [ 8 | 'y', 9 | 'xBlock' 10 | ], 11 | #category : #'MatplotLibBridge-Model' 12 | } 13 | 14 | { #category : #visiting } 15 | MLBXBlockLine >> acceptVisitor: visitor [ 16 | ^ visitor visitMLBXBlockLine: self 17 | ] 18 | 19 | { #category : #private } 20 | MLBXBlockLine >> x [ 21 | ^ self y collect: [ :data | self xBlock value: data ] 22 | ] 23 | 24 | { #category : #accessing } 25 | MLBXBlockLine >> xBlock [ 26 | ^ xBlock 27 | ] 28 | 29 | { #category : #accessing } 30 | MLBXBlockLine >> xBlock: anObject [ 31 | xBlock := anObject 32 | ] 33 | 34 | { #category : #private } 35 | MLBXBlockLine >> y [ 36 | ^ y 37 | ] 38 | 39 | { #category : #accessing } 40 | MLBXBlockLine >> y: aSequenceableCollection [ 41 | y := aSequenceableCollection 42 | ] 43 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBConfigurationUnfinished.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am the error raised when the configuration of a MLB object is not finished making the command generation impossible. 3 | " 4 | Class { 5 | #name : #MLBConfigurationUnfinished, 6 | #superclass : #Error, 7 | #instVars : [ 8 | 'object', 9 | 'selector' 10 | ], 11 | #category : #'MatplotLibBridge-Errors' 12 | } 13 | 14 | { #category : #accessing } 15 | MLBConfigurationUnfinished >> messageText [ 16 | ^ '{1}>>{2} should not be nil, it has to be configured.' format: { self object class name . self selector } 17 | ] 18 | 19 | { #category : #accessing } 20 | MLBConfigurationUnfinished >> object [ 21 | ^ object 22 | ] 23 | 24 | { #category : #accessing } 25 | MLBConfigurationUnfinished >> object: anObject [ 26 | object := anObject 27 | ] 28 | 29 | { #category : #accessing } 30 | MLBConfigurationUnfinished >> selector [ 31 | ^ selector 32 | ] 33 | 34 | { #category : #accessing } 35 | MLBConfigurationUnfinished >> selector: anObject [ 36 | selector := anObject 37 | ] 38 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBRcCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.rc. 3 | " 4 | Class { 5 | #name : #MLBRcCommand, 6 | #superclass : #MLBMatplotlibCommand, 7 | #instVars : [ 8 | 'group', 9 | 'attributesDict', 10 | 'labelsize', 11 | 'titlesize' 12 | ], 13 | #category : #'MatplotLibBridge-Commands-Core' 14 | } 15 | 16 | { #category : #accessing } 17 | MLBRcCommand >> functionName [ 18 | ^ 'rc' 19 | ] 20 | 21 | { #category : #accessing } 22 | MLBRcCommand >> group [ 23 | 24 | ^ group 25 | ] 26 | 27 | { #category : #accessing } 28 | MLBRcCommand >> group: anObject [ 29 | group := anObject 30 | ] 31 | 32 | { #category : #initialization } 33 | MLBRcCommand >> initialize [ 34 | super initialize. 35 | attributesDict := Dictionary new 36 | ] 37 | 38 | { #category : #accessing } 39 | MLBRcCommand >> mlbAttributesDict [ 40 | ^ attributesDict 41 | ] 42 | 43 | { #category : #accessing } 44 | MLBRcCommand >> setProperty: aString to: anObject [ 45 | attributesDict at: aString put: anObject 46 | ] 47 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBTitleCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.title function. 3 | " 4 | Class { 5 | #name : #MLBTitleCommand, 6 | #superclass : #MLBPyplotCommand, 7 | #instVars : [ 8 | 's', 9 | 'fontdict', 10 | 'loc' 11 | ], 12 | #category : #'MatplotLibBridge-Commands-Core' 13 | } 14 | 15 | { #category : #accessing } 16 | MLBTitleCommand >> fontdict [ 17 | 18 | ^ fontdict 19 | ] 20 | 21 | { #category : #accessing } 22 | MLBTitleCommand >> fontdict: anObject [ 23 | fontdict := anObject 24 | ] 25 | 26 | { #category : #accessing } 27 | MLBTitleCommand >> functionName [ 28 | ^ 'title' 29 | ] 30 | 31 | { #category : #accessing } 32 | MLBTitleCommand >> loc [ 33 | 34 | ^ loc 35 | ] 36 | 37 | { #category : #accessing } 38 | MLBTitleCommand >> loc: anObject [ 39 | loc := anObject 40 | ] 41 | 42 | { #category : #accessing } 43 | MLBTitleCommand >> s [ 44 | 45 | ^ s 46 | ] 47 | 48 | { #category : #accessing } 49 | MLBTitleCommand >> s: anObject [ 50 | s := anObject 51 | ] 52 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBAbstractPlot.extension.st: -------------------------------------------------------------------------------- 1 | Extension { #name : #MLBAbstractPlot } 2 | 3 | { #category : #'*MatplotLibBridge-Commands' } 4 | MLBAbstractPlot >> commandsList [ 5 | ^ MLBCommandListGenerator new 6 | visit: self; 7 | commandList 8 | ] 9 | 10 | { #category : #'*MatplotLibBridge-Commands' } 11 | MLBAbstractPlot >> generateIn: aFileReference [ 12 | self commandsList 13 | add: (MLBSaveFigCommand new 14 | filename: aFileReference fullName; 15 | bbox_inches: 'tight'; 16 | transparent: true; 17 | yourself); 18 | executeOptimized 19 | ] 20 | 21 | { #category : #'*MatplotLibBridge-Commands' } 22 | MLBAbstractPlot >> gtInspectorPython3CodeIn: composite [ 23 | 24 | composite text 25 | title: 'Python 3 code'; 26 | display: [ 27 | (self commandsList) 28 | optimizeGeneratedInstructions 29 | generate ] 30 | ] 31 | 32 | { #category : #'*MatplotLibBridge-Commands' } 33 | MLBAbstractPlot >> show [ 34 | self commandsList 35 | add: MLBShowCommand new; 36 | executeOptimized 37 | ] 38 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBStyleSheet.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a style sheet to be applied on a plot. 3 | 4 | I hold one or many MLBRcCommand. 5 | " 6 | Class { 7 | #name : #MLBStyleSheet, 8 | #superclass : #MLBVisitableObject, 9 | #instVars : [ 10 | 'properties' 11 | ], 12 | #category : #'MatplotLibBridge-Model' 13 | } 14 | 15 | { #category : #visiting } 16 | MLBStyleSheet >> acceptVisitor: visitor [ 17 | ^ visitor visitMLBStyleSheet: self 18 | ] 19 | 20 | { #category : #initialization } 21 | MLBStyleSheet >> initialize [ 22 | super initialize. 23 | properties := OrderedCollection new 24 | ] 25 | 26 | { #category : #accessing } 27 | MLBStyleSheet >> properties [ 28 | ^ properties 29 | ] 30 | 31 | { #category : #accessing } 32 | MLBStyleSheet >> properties: anObject [ 33 | properties := anObject 34 | ] 35 | 36 | { #category : #initialization } 37 | MLBStyleSheet >> setProperty: propertyName ofGroup: groupName to: anObject [ 38 | self properties 39 | add: (MLBStyleSheetProperty new 40 | groupName: groupName; 41 | name: propertyName; 42 | value: anObject; 43 | yourself) 44 | ] 45 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBXTicksCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.xticks function. 3 | " 4 | Class { 5 | #name : #MLBXTicksCommand, 6 | #superclass : #MLBPyplotCommand, 7 | #instVars : [ 8 | 'ticks', 9 | 'labels', 10 | 'rotation' 11 | ], 12 | #category : #'MatplotLibBridge-Commands-Core' 13 | } 14 | 15 | { #category : #accessing } 16 | MLBXTicksCommand >> functionName [ 17 | ^ 'xticks' 18 | ] 19 | 20 | { #category : #accessing } 21 | MLBXTicksCommand >> labels [ 22 | 23 | ^ labels 24 | ] 25 | 26 | { #category : #accessing } 27 | MLBXTicksCommand >> labels: anObject [ 28 | labels := anObject 29 | ] 30 | 31 | { #category : #accessing } 32 | MLBXTicksCommand >> rotation [ 33 | 34 | ^ rotation 35 | ] 36 | 37 | { #category : #accessing } 38 | MLBXTicksCommand >> rotation: anObject [ 39 | rotation := anObject 40 | ] 41 | 42 | { #category : #accessing } 43 | MLBXTicksCommand >> ticks [ 44 | 45 | ^ ticks 46 | ] 47 | 48 | { #category : #accessing } 49 | MLBXTicksCommand >> ticks: anObject [ 50 | ticks := anObject 51 | ] 52 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBYTicksCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.yticks function. 3 | " 4 | Class { 5 | #name : #MLBYTicksCommand, 6 | #superclass : #MLBPyplotCommand, 7 | #instVars : [ 8 | 'ticks', 9 | 'labels', 10 | 'rotation' 11 | ], 12 | #category : #'MatplotLibBridge-Commands-Core' 13 | } 14 | 15 | { #category : #accessing } 16 | MLBYTicksCommand >> functionName [ 17 | ^ 'yticks' 18 | ] 19 | 20 | { #category : #accessing } 21 | MLBYTicksCommand >> labels [ 22 | 23 | ^ labels 24 | ] 25 | 26 | { #category : #accessing } 27 | MLBYTicksCommand >> labels: anObject [ 28 | labels := anObject 29 | ] 30 | 31 | { #category : #accessing } 32 | MLBYTicksCommand >> rotation [ 33 | 34 | ^ rotation 35 | ] 36 | 37 | { #category : #accessing } 38 | MLBYTicksCommand >> rotation: anObject [ 39 | rotation := anObject 40 | ] 41 | 42 | { #category : #accessing } 43 | MLBYTicksCommand >> ticks [ 44 | 45 | ^ ticks 46 | ] 47 | 48 | { #category : #accessing } 49 | MLBYTicksCommand >> ticks: anObject [ 50 | ticks := anObject 51 | ] 52 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Julien Delplanque 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBXkcdCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.xkcd function. 3 | " 4 | Class { 5 | #name : #MLBXkcdCommand, 6 | #superclass : #MLBPyplotCommand, 7 | #instVars : [ 8 | 'scale', 9 | 'length', 10 | 'randomness' 11 | ], 12 | #category : #'MatplotLibBridge-Commands-Core' 13 | } 14 | 15 | { #category : #accessing } 16 | MLBXkcdCommand >> functionName [ 17 | ^ 'xkcd' 18 | ] 19 | 20 | { #category : #'as yet unclassified' } 21 | MLBXkcdCommand >> generateCommandsIn: aMLBCommandList [ 22 | aMLBCommandList add: self 23 | ] 24 | 25 | { #category : #accessing } 26 | MLBXkcdCommand >> length [ 27 | 28 | ^ length 29 | ] 30 | 31 | { #category : #accessing } 32 | MLBXkcdCommand >> length: anObject [ 33 | length := anObject 34 | ] 35 | 36 | { #category : #accessing } 37 | MLBXkcdCommand >> randomness [ 38 | 39 | ^ randomness 40 | ] 41 | 42 | { #category : #accessing } 43 | MLBXkcdCommand >> randomness: anObject [ 44 | randomness := anObject 45 | ] 46 | 47 | { #category : #accessing } 48 | MLBXkcdCommand >> scale [ 49 | 50 | ^ scale 51 | ] 52 | 53 | { #category : #accessing } 54 | MLBXkcdCommand >> scale: anObject [ 55 | scale := anObject 56 | ] 57 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBStyleSheetProperty.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I model a property of a stylesheet. 3 | 4 | I must provide: 5 | - #groupName : a String being the group I belong to. 6 | - #name : a String being the name of the property. 7 | - #value : an Object being the value of the property. 8 | " 9 | Class { 10 | #name : #MLBStyleSheetProperty, 11 | #superclass : #MLBVisitableObject, 12 | #instVars : [ 13 | 'groupName', 14 | 'name', 15 | 'value' 16 | ], 17 | #category : #'MatplotLibBridge-Model' 18 | } 19 | 20 | { #category : #visiting } 21 | MLBStyleSheetProperty >> acceptVisitor: visitor [ 22 | ^ visitor visitMLBStyleSheetProperty: self 23 | ] 24 | 25 | { #category : #accessing } 26 | MLBStyleSheetProperty >> groupName [ 27 | ^ groupName 28 | ] 29 | 30 | { #category : #accessing } 31 | MLBStyleSheetProperty >> groupName: anObject [ 32 | groupName := anObject 33 | ] 34 | 35 | { #category : #accessing } 36 | MLBStyleSheetProperty >> name [ 37 | ^ name 38 | ] 39 | 40 | { #category : #accessing } 41 | MLBStyleSheetProperty >> name: anObject [ 42 | name := anObject 43 | ] 44 | 45 | { #category : #accessing } 46 | MLBStyleSheetProperty >> value [ 47 | ^ value 48 | ] 49 | 50 | { #category : #accessing } 51 | MLBStyleSheetProperty >> value: anObject [ 52 | value := anObject 53 | ] 54 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBScatterPlot2.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a second implementation of a high-level object to draw scatter plot from matplotlib. 3 | 4 | I use MLBScatterData instead of MLBCircle. 5 | 6 | I allow to change the marker used for plotting. 7 | " 8 | Class { 9 | #name : #MLBScatterPlot2, 10 | #superclass : #MLBAbstractPlot, 11 | #instVars : [ 12 | 'data', 13 | 'markersOrder' 14 | ], 15 | #category : #'MatplotLibBridge-Model' 16 | } 17 | 18 | { #category : #example } 19 | MLBScatterPlot2 class >> example [ 20 | MLBExamples exampleScatterplot2 21 | ] 22 | 23 | { #category : #visiting } 24 | MLBScatterPlot2 >> acceptVisitor: visitor [ 25 | ^ visitor visitMLBScatterPlot2: self 26 | ] 27 | 28 | { #category : #accessing } 29 | MLBScatterPlot2 >> data [ 30 | ^ data 31 | ] 32 | 33 | { #category : #accessing } 34 | MLBScatterPlot2 >> data: aCollectionOfMLBScatterData [ 35 | data := aCollectionOfMLBScatterData 36 | ] 37 | 38 | { #category : #initialization } 39 | MLBScatterPlot2 >> initialize [ 40 | super initialize. 41 | self 42 | markersOrder: #() 43 | ] 44 | 45 | { #category : #accessing } 46 | MLBScatterPlot2 >> markersOrder [ 47 | ^ markersOrder 48 | ] 49 | 50 | { #category : #accessing } 51 | MLBScatterPlot2 >> markersOrder: anObject [ 52 | markersOrder := anObject 53 | ] 54 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBScatterPlot.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a high-level object to draw scatter plot from matplotlib. 3 | " 4 | Class { 5 | #name : #MLBScatterPlot, 6 | #superclass : #MLBAbstractPlot, 7 | #instVars : [ 8 | 'circles', 9 | 'marker' 10 | ], 11 | #category : #'MatplotLibBridge-Model' 12 | } 13 | 14 | { #category : #example } 15 | MLBScatterPlot class >> example [ 16 | MLBExamples exampleScatterplot 17 | ] 18 | 19 | { #category : #visiting } 20 | MLBScatterPlot >> acceptVisitor: visitor [ 21 | ^ visitor visitMLBScatterPlot: self 22 | ] 23 | 24 | { #category : #accessing } 25 | MLBScatterPlot >> circles [ 26 | ^ circles 27 | ] 28 | 29 | { #category : #accessing } 30 | MLBScatterPlot >> circles: anObject [ 31 | circles := anObject 32 | ] 33 | 34 | { #category : #private } 35 | MLBScatterPlot >> colors [ 36 | ^ self circles collect: #color 37 | ] 38 | 39 | { #category : #accessing } 40 | MLBScatterPlot >> marker [ 41 | ^ marker 42 | ] 43 | 44 | { #category : #accessing } 45 | MLBScatterPlot >> marker: anObject [ 46 | marker := anObject 47 | ] 48 | 49 | { #category : #private } 50 | MLBScatterPlot >> pointSizes [ 51 | ^ self circles collect: #size 52 | ] 53 | 54 | { #category : #private } 55 | MLBScatterPlot >> x [ 56 | ^ self circles collect: #x 57 | ] 58 | 59 | { #category : #private } 60 | MLBScatterPlot >> y [ 61 | ^ self circles collect: #y 62 | ] 63 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBCircle.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a circle used in a MLBScatterPlot. 3 | " 4 | Class { 5 | #name : #MLBCircle, 6 | #superclass : #Object, 7 | #instVars : [ 8 | 'position', 9 | 'size', 10 | 'color' 11 | ], 12 | #category : #'MatplotLibBridge-Model' 13 | } 14 | 15 | { #category : #'instance creation' } 16 | MLBCircle class >> position: aPoint [ 17 | ^ self new 18 | position: aPoint; 19 | yourself 20 | ] 21 | 22 | { #category : #'instance creation' } 23 | MLBCircle class >> position: aPoint size: size [ 24 | ^ self new 25 | position: aPoint; 26 | size: size; 27 | yourself 28 | ] 29 | 30 | { #category : #accessing } 31 | MLBCircle >> color [ 32 | ^ color 33 | ] 34 | 35 | { #category : #accessing } 36 | MLBCircle >> color: anObject [ 37 | color := anObject 38 | ] 39 | 40 | { #category : #initialization } 41 | MLBCircle >> initialize [ 42 | super initialize. 43 | self 44 | color: Color black; 45 | size: 5 46 | ] 47 | 48 | { #category : #accessing } 49 | MLBCircle >> position [ 50 | ^ position 51 | ] 52 | 53 | { #category : #accessing } 54 | MLBCircle >> position: anObject [ 55 | position := anObject 56 | ] 57 | 58 | { #category : #accessing } 59 | MLBCircle >> size [ 60 | ^ size 61 | ] 62 | 63 | { #category : #accessing } 64 | MLBCircle >> size: anObject [ 65 | size := anObject 66 | ] 67 | 68 | { #category : #accessing } 69 | MLBCircle >> x [ 70 | ^ self position x 71 | ] 72 | 73 | { #category : #accessing } 74 | MLBCircle >> y [ 75 | ^ self position y 76 | ] 77 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBBarPlot.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a high-level object to draw bar plot from matplotlib. 3 | " 4 | Class { 5 | #name : #MLBBarPlot, 6 | #superclass : #MLBAbstractBarPlot, 7 | #instVars : [ 8 | 'data', 9 | 'color', 10 | 'errorBars', 11 | 'errorBarsColor' 12 | ], 13 | #category : #'MatplotLibBridge-Model' 14 | } 15 | 16 | { #category : #example } 17 | MLBBarPlot class >> example [ 18 | MLBExamples exampleBarplot 19 | ] 20 | 21 | { #category : #visiting } 22 | MLBBarPlot >> acceptVisitor: visitor [ 23 | ^ visitor visitMLBBarPlot: self 24 | ] 25 | 26 | { #category : #accessing } 27 | MLBBarPlot >> color [ 28 | ^ color 29 | ] 30 | 31 | { #category : #accessing } 32 | MLBBarPlot >> color: anObject [ 33 | color := anObject 34 | ] 35 | 36 | { #category : #accessing } 37 | MLBBarPlot >> data [ 38 | ^ data 39 | ] 40 | 41 | { #category : #accessing } 42 | MLBBarPlot >> data: anObject [ 43 | data := anObject 44 | ] 45 | 46 | { #category : #accessing } 47 | MLBBarPlot >> errorBars [ 48 | ^ errorBars 49 | ] 50 | 51 | { #category : #accessing } 52 | MLBBarPlot >> errorBars: anObject [ 53 | errorBars := anObject 54 | ] 55 | 56 | { #category : #accessing } 57 | MLBBarPlot >> errorBarsColor [ 58 | ^ errorBarsColor 59 | ] 60 | 61 | { #category : #accessing } 62 | MLBBarPlot >> errorBarsColor: anObject [ 63 | errorBarsColor := anObject 64 | ] 65 | 66 | { #category : #initialization } 67 | MLBBarPlot >> initialize [ 68 | super initialize. 69 | self 70 | errorBarsColor: Color black; 71 | color: Color gray 72 | ] 73 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBStackedBarPlot.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a high-level object to draw stacked bar plot from matplotlib. 3 | " 4 | Class { 5 | #name : #MLBStackedBarPlot, 6 | #superclass : #MLBAbstractBarPlot, 7 | #instVars : [ 8 | 'dataList', 9 | 'colorList', 10 | 'errorBarsList', 11 | 'errorBarsColorList' 12 | ], 13 | #category : #'MatplotLibBridge-Model' 14 | } 15 | 16 | { #category : #example } 17 | MLBStackedBarPlot class >> example [ 18 | MLBExamples exampleStackedBarplot 19 | ] 20 | 21 | { #category : #visiting } 22 | MLBStackedBarPlot >> acceptVisitor: visitor [ 23 | ^ visitor visitMLBStackedBarPlot: self 24 | ] 25 | 26 | { #category : #accessing } 27 | MLBStackedBarPlot >> colorList [ 28 | ^ colorList 29 | ] 30 | 31 | { #category : #accessing } 32 | MLBStackedBarPlot >> colorList: anObject [ 33 | colorList := anObject 34 | ] 35 | 36 | { #category : #accessing } 37 | MLBStackedBarPlot >> dataList [ 38 | ^ dataList 39 | ] 40 | 41 | { #category : #accessing } 42 | MLBStackedBarPlot >> dataList: anObject [ 43 | dataList := anObject 44 | ] 45 | 46 | { #category : #accessing } 47 | MLBStackedBarPlot >> errorBarsColorList [ 48 | ^ errorBarsColorList 49 | ] 50 | 51 | { #category : #accessing } 52 | MLBStackedBarPlot >> errorBarsColorList: anObject [ 53 | errorBarsColorList := anObject 54 | ] 55 | 56 | { #category : #accessing } 57 | MLBStackedBarPlot >> errorBarsList [ 58 | ^ errorBarsList 59 | ] 60 | 61 | { #category : #accessing } 62 | MLBStackedBarPlot >> errorBarsList: anObject [ 63 | errorBarsList := anObject 64 | ] 65 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBPointsLine.class.st: -------------------------------------------------------------------------------- 1 | " 2 | A line defined point-by-point. 3 | " 4 | Class { 5 | #name : #MLBPointsLine, 6 | #superclass : #MLBLine, 7 | #instVars : [ 8 | 'points' 9 | ], 10 | #category : #'MatplotLibBridge-Model' 11 | } 12 | 13 | { #category : #example } 14 | MLBPointsLine class >> example [ 15 | "To use it in a MLBLinePlot, please use #addPointsLine: message with a block as argument 16 | to set-up the MLBPointsLine instance." 17 | ^ MLBPointsLine new 18 | points: { 1@1 . 2@2 . 3@3 }; 19 | yourself 20 | ] 21 | 22 | { #category : #example } 23 | MLBPointsLine class >> example2 [ 24 | "Alternative way to instantiate a MLBPointsLine. Specify x and y as separated arrays." 25 | ^ MLBPointsLine new 26 | x: #(1 2 3) y: #(1 2 3); 27 | yourself 28 | ] 29 | 30 | { #category : #visiting } 31 | MLBPointsLine >> acceptVisitor: visitor [ 32 | ^ visitor visitMLBPointsLine: self 33 | ] 34 | 35 | { #category : #initialization } 36 | MLBPointsLine >> initialize [ 37 | super initialize. 38 | self 39 | points: #() 40 | ] 41 | 42 | { #category : #accessing } 43 | MLBPointsLine >> points [ 44 | ^ points 45 | ] 46 | 47 | { #category : #accessing } 48 | MLBPointsLine >> points: anObject [ 49 | points := anObject 50 | ] 51 | 52 | { #category : #private } 53 | MLBPointsLine >> x [ 54 | ^ self points collect: #x 55 | ] 56 | 57 | { #category : #accessing } 58 | MLBPointsLine >> x: anArrayOfXs y: anArrayOfYs [ 59 | self points: anArrayOfXs @ anArrayOfYs 60 | ] 61 | 62 | { #category : #private } 63 | MLBPointsLine >> y [ 64 | ^ self points collect: #y 65 | ] 66 | -------------------------------------------------------------------------------- /src/BaselineOfMatplotLibBridge/BaselineOfMatplotLibBridge.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #BaselineOfMatplotLibBridge, 3 | #superclass : #BaselineOf, 4 | #category : 'BaselineOfMatplotLibBridge' 5 | } 6 | 7 | { #category : #baseline } 8 | BaselineOfMatplotLibBridge >> baseline: spec [ 9 | 10 | spec 11 | for: #common 12 | do: [ 13 | self 14 | definePackages: spec; 15 | defineDependencies: spec; 16 | defineGroups: spec ] 17 | ] 18 | 19 | { #category : #baseline } 20 | BaselineOfMatplotLibBridge >> defineDependencies: spec [ 21 | ^ spec 22 | baseline: 'Atlas' with: [ 23 | spec repository: 'github://kilon/Atlas']; 24 | baseline: 'Python3Generator' with: [ 25 | spec repository: 'github://juliendelplanque/Python3Generator:v2.0.0/src']; 26 | yourself 27 | ] 28 | 29 | { #category : #baseline } 30 | BaselineOfMatplotLibBridge >> defineGroups: spec [ 31 | spec 32 | group: 'default' with: #('MatplotLibBridge' 'MatplotLibBridge-Commands' 'MatplotLibBridge-Tests'); 33 | group: 'atlas' with: #('default' 'MatplotLibBridge-Atlas') 34 | ] 35 | 36 | { #category : #baseline } 37 | BaselineOfMatplotLibBridge >> definePackages: spec [ 38 | ^ spec 39 | package: 'MatplotLibBridge' with: [ spec requires: #('Python3Generator') ]; 40 | package: 'MatplotLibBridge-Commands' with: [ spec requires: #('MatplotLibBridge' 'Python3Generator') ]; 41 | package: 'MatplotLibBridge-Tests' with: [ spec requires: #('MatplotLibBridge' 'MatplotLibBridge-Commands') ]; 42 | package: 'MatplotLibBridge-Atlas' with: [ spec requires: #('Atlas' 'MatplotLibBridge') ]; 43 | yourself 44 | ] 45 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBBoxPlot.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a high-level object to draw box plot from matplotlib. 3 | " 4 | Class { 5 | #name : #MLBBoxPlot, 6 | #superclass : #MLBAbstractPlot, 7 | #instVars : [ 8 | 'dataList', 9 | 'labels', 10 | 'vertical' 11 | ], 12 | #category : #'MatplotLibBridge-Model' 13 | } 14 | 15 | { #category : #example } 16 | MLBBoxPlot class >> exampleHorizontal [ 17 | MLBExamples exampleHorizontalBoxplot 18 | ] 19 | 20 | { #category : #example } 21 | MLBBoxPlot class >> exampleVertical [ 22 | MLBExamples exampleVerticalBoxplot 23 | ] 24 | 25 | { #category : #visiting } 26 | MLBBoxPlot >> acceptVisitor: visitor [ 27 | ^ visitor visitMLBBoxPlot: self 28 | ] 29 | 30 | { #category : #setting } 31 | MLBBoxPlot >> beHorizontal [ 32 | self vertical: false 33 | ] 34 | 35 | { #category : #setting } 36 | MLBBoxPlot >> beVertical [ 37 | self vertical: true 38 | ] 39 | 40 | { #category : #accessing } 41 | MLBBoxPlot >> dataList [ 42 | ^ dataList 43 | ] 44 | 45 | { #category : #accessing } 46 | MLBBoxPlot >> dataList: anObject [ 47 | dataList := anObject 48 | ] 49 | 50 | { #category : #initialization } 51 | MLBBoxPlot >> initialize [ 52 | super initialize. 53 | self beVertical 54 | ] 55 | 56 | { #category : #testing } 57 | MLBBoxPlot >> isHorizontal [ 58 | ^ self isVertical not 59 | ] 60 | 61 | { #category : #testing } 62 | MLBBoxPlot >> isVertical [ 63 | ^ self vertical 64 | ] 65 | 66 | { #category : #accessing } 67 | MLBBoxPlot >> labels [ 68 | ^ labels 69 | ] 70 | 71 | { #category : #accessing } 72 | MLBBoxPlot >> labels: anObject [ 73 | labels := anObject 74 | ] 75 | 76 | { #category : #accessing } 77 | MLBBoxPlot >> vertical [ 78 | ^ vertical 79 | ] 80 | 81 | { #category : #accessing } 82 | MLBBoxPlot >> vertical: anObject [ 83 | vertical := anObject 84 | ] 85 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBStyle.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am an abstract style for an item in a plot. 3 | 4 | See my subclasses for concrete examples. 5 | " 6 | Class { 7 | #name : #MLBStyle, 8 | #superclass : #Object, 9 | #instVars : [ 10 | 'styleString' 11 | ], 12 | #category : #'MatplotLibBridge-Core' 13 | } 14 | 15 | { #category : #checking } 16 | MLBStyle class >> checkValidStyleString: aString [ 17 | (self isValidStyleString: aString) 18 | ifFalse: [ self 19 | error: aString , ' is not a valid style string for ' , self name ] 20 | ] 21 | 22 | { #category : #testing } 23 | MLBStyle class >> isValidStyleString: aString [ 24 | ^ self validStyleStrings includes: aString 25 | ] 26 | 27 | { #category : #'instance creation' } 28 | MLBStyle class >> new [ 29 | self error: 'Uses #styleString: to create a new instance of myself.' 30 | ] 31 | 32 | { #category : #'instance creation' } 33 | MLBStyle class >> random [ 34 | ^ self styleString: self validStyleStrings atRandom 35 | ] 36 | 37 | { #category : #'instance creation' } 38 | MLBStyle class >> styleString: aString [ 39 | ^ self basicNew 40 | styleString: aString; 41 | yourself 42 | ] 43 | 44 | { #category : #accessing } 45 | MLBStyle class >> validStyleStrings [ 46 | "Returns the list of strings that are valid to instantiate the object." 47 | ^ self subclassResponsibility 48 | ] 49 | 50 | { #category : #accessing } 51 | MLBStyle >> styleString [ 52 | ^ styleString 53 | ] 54 | 55 | { #category : #accessing } 56 | MLBStyle >> styleString: anObject [ 57 | self class checkValidStyleString: anObject. 58 | styleString := anObject 59 | ] 60 | 61 | { #category : #writing } 62 | MLBStyle >> writePython3On: aStream [ 63 | "When we reach python code generation, this object is just serialized as a String." 64 | self styleString writePython3On: aStream 65 | ] 66 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBLegend.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I represent the legend of a line plot. 3 | " 4 | Class { 5 | #name : #MLBLegend, 6 | #superclass : #MLBVisitableObject, 7 | #instVars : [ 8 | 'location', 9 | 'numberOfColumns', 10 | 'fontSize', 11 | 'hasFancyBox', 12 | 'hasShadow', 13 | 'frameTransparency', 14 | 'title' 15 | ], 16 | #category : #'MatplotLibBridge-Model' 17 | } 18 | 19 | { #category : #visiting } 20 | MLBLegend >> acceptVisitor: visitor [ 21 | ^ visitor visitMLBLegend: self 22 | ] 23 | 24 | { #category : #accessing } 25 | MLBLegend >> fontSize [ 26 | ^ fontSize 27 | ] 28 | 29 | { #category : #accessing } 30 | MLBLegend >> fontSize: anObject [ 31 | fontSize := anObject 32 | ] 33 | 34 | { #category : #accessing } 35 | MLBLegend >> frameTransparency [ 36 | ^ frameTransparency 37 | ] 38 | 39 | { #category : #accessing } 40 | MLBLegend >> frameTransparency: anObject [ 41 | frameTransparency := anObject 42 | ] 43 | 44 | { #category : #accessing } 45 | MLBLegend >> hasFancyBox [ 46 | ^ hasFancyBox 47 | ] 48 | 49 | { #category : #accessing } 50 | MLBLegend >> hasFancyBox: anObject [ 51 | hasFancyBox := anObject 52 | ] 53 | 54 | { #category : #accessing } 55 | MLBLegend >> hasShadow [ 56 | ^ hasShadow 57 | ] 58 | 59 | { #category : #accessing } 60 | MLBLegend >> hasShadow: anObject [ 61 | hasShadow := anObject 62 | ] 63 | 64 | { #category : #accessing } 65 | MLBLegend >> location [ 66 | ^ location 67 | ] 68 | 69 | { #category : #accessing } 70 | MLBLegend >> location: anObject [ 71 | location := anObject 72 | ] 73 | 74 | { #category : #accessing } 75 | MLBLegend >> numberOfColumns [ 76 | ^ numberOfColumns 77 | ] 78 | 79 | { #category : #accessing } 80 | MLBLegend >> numberOfColumns: anObject [ 81 | numberOfColumns := anObject 82 | ] 83 | 84 | { #category : #accessing } 85 | MLBLegend >> title [ 86 | ^ title 87 | ] 88 | 89 | { #category : #accessing } 90 | MLBLegend >> title: anObject [ 91 | title := anObject 92 | ] 93 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBScatterData.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am some data used in a MLBScatterPlot2. 3 | " 4 | Class { 5 | #name : #MLBScatterData, 6 | #superclass : #Object, 7 | #instVars : [ 8 | 'position', 9 | 'color', 10 | 'size', 11 | 'marker' 12 | ], 13 | #category : #'MatplotLibBridge-Model' 14 | } 15 | 16 | { #category : #'instance creation' } 17 | MLBScatterData class >> position: aPoint [ 18 | ^ self new 19 | position: aPoint; 20 | yourself 21 | ] 22 | 23 | { #category : #'instance creation' } 24 | MLBScatterData class >> position: aPoint size: size [ 25 | ^ self new 26 | position: aPoint; 27 | size: size; 28 | yourself 29 | ] 30 | 31 | { #category : #accessing } 32 | MLBScatterData >> color [ 33 | ^ color 34 | ] 35 | 36 | { #category : #accessing } 37 | MLBScatterData >> color: anObject [ 38 | color := anObject 39 | ] 40 | 41 | { #category : #initialization } 42 | MLBScatterData >> initialize [ 43 | super initialize. 44 | self 45 | color: Color black; 46 | size: 5; 47 | marker: 'o' 48 | ] 49 | 50 | { #category : #accessing } 51 | MLBScatterData >> marker [ 52 | ^ marker 53 | ] 54 | 55 | { #category : #accessing } 56 | MLBScatterData >> marker: anObject [ 57 | marker := anObject asMLBMarkerStyle 58 | ] 59 | 60 | { #category : #accessing } 61 | MLBScatterData >> position [ 62 | ^ position 63 | ] 64 | 65 | { #category : #accessing } 66 | MLBScatterData >> position: anObject [ 67 | position := anObject 68 | ] 69 | 70 | { #category : #accessing } 71 | MLBScatterData >> size [ 72 | ^ size 73 | ] 74 | 75 | { #category : #accessing } 76 | MLBScatterData >> size: anObject [ 77 | size := anObject 78 | ] 79 | 80 | { #category : #accessing } 81 | MLBScatterData >> x [ 82 | ^ self position x 83 | ] 84 | 85 | { #category : #accessing } 86 | MLBScatterData >> x: aNumber [ 87 | self position x: aNumber 88 | ] 89 | 90 | { #category : #accessing } 91 | MLBScatterData >> y [ 92 | ^ self position y 93 | ] 94 | 95 | { #category : #accessing } 96 | MLBScatterData >> y: aNumber [ 97 | self position y: aNumber 98 | ] 99 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBAnnotation.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am an annotation on the plot. 3 | " 4 | Class { 5 | #name : #MLBAnnotation, 6 | #superclass : #MLBVisitableObject, 7 | #instVars : [ 8 | 'content', 9 | 'position', 10 | 'textPosition', 11 | 'arrowProperties', 12 | 'onlyVisibleInsideAxes' 13 | ], 14 | #category : #'MatplotLibBridge-Model' 15 | } 16 | 17 | { #category : #visiting } 18 | MLBAnnotation >> acceptVisitor: visitor [ 19 | ^ visitor visitMLBAnnotation: self 20 | ] 21 | 22 | { #category : #accessing } 23 | MLBAnnotation >> arrowProperties [ 24 | ^ arrowProperties 25 | ] 26 | 27 | { #category : #accessing } 28 | MLBAnnotation >> arrowProperties: anObject [ 29 | arrowProperties := anObject 30 | ] 31 | 32 | { #category : #accessing } 33 | MLBAnnotation >> content [ 34 | ^ content 35 | ] 36 | 37 | { #category : #accessing } 38 | MLBAnnotation >> content: anObject [ 39 | content := anObject 40 | ] 41 | 42 | { #category : #initialization } 43 | MLBAnnotation >> initialize [ 44 | super initialize. 45 | self 46 | arrowProperties: Dictionary new; 47 | content: ''; 48 | onlyVisibleInsideAxes: true 49 | ] 50 | 51 | { #category : #accessing } 52 | MLBAnnotation >> onlyVisibleInsideAxes [ 53 | ^ onlyVisibleInsideAxes 54 | ] 55 | 56 | { #category : #accessing } 57 | MLBAnnotation >> onlyVisibleInsideAxes: anObject [ 58 | onlyVisibleInsideAxes := anObject 59 | ] 60 | 61 | { #category : #accessing } 62 | MLBAnnotation >> position [ 63 | ^ position 64 | ] 65 | 66 | { #category : #accessing } 67 | MLBAnnotation >> position: anObject [ 68 | position := anObject 69 | ] 70 | 71 | { #category : #accessing } 72 | MLBAnnotation >> textPosition [ 73 | ^ textPosition 74 | ] 75 | 76 | { #category : #accessing } 77 | MLBAnnotation >> textPosition: anObject [ 78 | textPosition := anObject 79 | ] 80 | 81 | { #category : #verification } 82 | MLBAnnotation >> verifyArrowProperties: aDictionary [ 83 | (aDictionary includesKey: 'arrowstyle') 84 | ifFalse: [ ^ self ]. 85 | 86 | aDictionary 87 | at: 'arrowstyle' 88 | put: (aDictionary at: 'arrowstyle') asMLBArrowStyle 89 | ] 90 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBAbstractBarPlot.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a super class for all boxplot classes. 3 | " 4 | Class { 5 | #name : #MLBAbstractBarPlot, 6 | #superclass : #MLBAbstractPlot, 7 | #instVars : [ 8 | 'align', 9 | 'barWidth', 10 | 'logAxis', 11 | 'labels', 12 | 'alignLabelRightEdge' 13 | ], 14 | #category : #'MatplotLibBridge-Model' 15 | } 16 | 17 | { #category : #accessing } 18 | MLBAbstractBarPlot >> align [ 19 | ^ align 20 | ] 21 | 22 | { #category : #accessing } 23 | MLBAbstractBarPlot >> align: anObject [ 24 | align := anObject 25 | ] 26 | 27 | { #category : #alignment } 28 | MLBAbstractBarPlot >> alignLabelCenter [ 29 | alignLabelRightEdge := false. 30 | self align: 'center' 31 | ] 32 | 33 | { #category : #alignment } 34 | MLBAbstractBarPlot >> alignLabelEdge [ 35 | self 36 | deprecated: 'Please use #alignLabelLeftEdge instead.' 37 | transformWith: '`@receiver alignLabelEdge' -> '`@receiver alignLabelLeftEdge'. 38 | self alignLabelLeftEdge 39 | ] 40 | 41 | { #category : #alignment } 42 | MLBAbstractBarPlot >> alignLabelLeftEdge [ 43 | alignLabelRightEdge := false. 44 | self align: 'edge' 45 | ] 46 | 47 | { #category : #alignment } 48 | MLBAbstractBarPlot >> alignLabelRightEdge [ 49 | alignLabelRightEdge := true. 50 | self align: 'edge' 51 | ] 52 | 53 | { #category : #accessing } 54 | MLBAbstractBarPlot >> barWidth [ 55 | ^ barWidth 56 | ] 57 | 58 | { #category : #accessing } 59 | MLBAbstractBarPlot >> barWidth: anObject [ 60 | barWidth := anObject 61 | ] 62 | 63 | { #category : #initialization } 64 | MLBAbstractBarPlot >> initialize [ 65 | super initialize. 66 | alignLabelRightEdge := false. 67 | self 68 | alignLabelCenter; 69 | barWidth: 0.35; 70 | logAxis: false 71 | ] 72 | 73 | { #category : #testing } 74 | MLBAbstractBarPlot >> isAlignLabelRightEdge [ 75 | ^ alignLabelRightEdge 76 | ] 77 | 78 | { #category : #accessing } 79 | MLBAbstractBarPlot >> labels [ 80 | ^ labels 81 | ] 82 | 83 | { #category : #accessing } 84 | MLBAbstractBarPlot >> labels: anObject [ 85 | labels := anObject 86 | ] 87 | 88 | { #category : #accessing } 89 | MLBAbstractBarPlot >> logAxis [ 90 | ^ logAxis 91 | ] 92 | 93 | { #category : #accessing } 94 | MLBAbstractBarPlot >> logAxis: anObject [ 95 | logAxis := anObject 96 | ] 97 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBPiePlot.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a high-level object to draw pie plot from matplotlib. 3 | " 4 | Class { 5 | #name : #MLBPiePlot, 6 | #superclass : #MLBAbstractPlot, 7 | #instVars : [ 8 | 'data', 9 | 'labels', 10 | 'hasShadow', 11 | 'explode', 12 | 'startAngle', 13 | 'radius', 14 | 'isCounterClock', 15 | 'colors' 16 | ], 17 | #category : #'MatplotLibBridge-Model' 18 | } 19 | 20 | { #category : #example } 21 | MLBPiePlot class >> example [ 22 | MLBExamples examplePieplot 23 | ] 24 | 25 | { #category : #visiting } 26 | MLBPiePlot >> acceptVisitor: visitor [ 27 | ^ visitor visitMLBPiePlot: self 28 | ] 29 | 30 | { #category : #accessing } 31 | MLBPiePlot >> colors [ 32 | ^ colors 33 | ] 34 | 35 | { #category : #accessing } 36 | MLBPiePlot >> colors: anObject [ 37 | colors := anObject 38 | ] 39 | 40 | { #category : #accessing } 41 | MLBPiePlot >> data [ 42 | ^ data 43 | ] 44 | 45 | { #category : #accessing } 46 | MLBPiePlot >> data: anObject [ 47 | data := anObject 48 | ] 49 | 50 | { #category : #accessing } 51 | MLBPiePlot >> explode [ 52 | ^ explode 53 | ] 54 | 55 | { #category : #accessing } 56 | MLBPiePlot >> explode: anObject [ 57 | explode := anObject 58 | ] 59 | 60 | { #category : #accessing } 61 | MLBPiePlot >> hasShadow [ 62 | ^ hasShadow 63 | ] 64 | 65 | { #category : #accessing } 66 | MLBPiePlot >> hasShadow: anObject [ 67 | hasShadow := anObject 68 | ] 69 | 70 | { #category : #initialization } 71 | MLBPiePlot >> initialize [ 72 | super initialize. 73 | self 74 | hasShadow: false; 75 | isCounterClock: true 76 | ] 77 | 78 | { #category : #accessing } 79 | MLBPiePlot >> isCounterClock [ 80 | ^ isCounterClock 81 | ] 82 | 83 | { #category : #accessing } 84 | MLBPiePlot >> isCounterClock: anObject [ 85 | isCounterClock := anObject 86 | ] 87 | 88 | { #category : #accessing } 89 | MLBPiePlot >> labels [ 90 | ^ labels 91 | ] 92 | 93 | { #category : #accessing } 94 | MLBPiePlot >> labels: anObject [ 95 | labels := anObject 96 | ] 97 | 98 | { #category : #accessing } 99 | MLBPiePlot >> radius [ 100 | ^ radius 101 | ] 102 | 103 | { #category : #accessing } 104 | MLBPiePlot >> radius: anObject [ 105 | radius := anObject 106 | ] 107 | 108 | { #category : #accessing } 109 | MLBPiePlot >> startAngle [ 110 | ^ startAngle 111 | ] 112 | 113 | { #category : #accessing } 114 | MLBPiePlot >> startAngle: anObject [ 115 | startAngle := anObject 116 | ] 117 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBFigureCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.figure function. 3 | 4 | From the doc, I can be configured with: 5 | - num : integer or string, optional, default: none If not provided, a new figure will be created, and the figure number will be incremented. The figure objects holds this number in a number attribute. If num is provided, and a figure with this id already exists, make it active, and returns a reference to it. If this figure does not exists, create it and returns it. If num is a string, the window title will be set to this figure’s num. 6 | 7 | -figsize : tuple of integers, optional, default: None width, height in inches. If not provided, defaults to rc figure.figsize. 8 | 9 | -dpi : integer, optional, default: None resolution of the figure. If not provided, defaults to rc figure.dpi. 10 | 11 | -facecolor : the background color. If not provided, defaults to rc figure.facecolor 12 | 13 | -edgecolor : the border color. If not provided, defaults to rc figure.edgecolor 14 | " 15 | Class { 16 | #name : #MLBFigureCommand, 17 | #superclass : #MLBPyplotCommand, 18 | #instVars : [ 19 | 'num', 20 | 'figsize', 21 | 'dpi', 22 | 'facecolor', 23 | 'edgecolor' 24 | ], 25 | #category : #'MatplotLibBridge-Commands-Core' 26 | } 27 | 28 | { #category : #accessing } 29 | MLBFigureCommand >> dpi [ 30 | 31 | ^ dpi 32 | ] 33 | 34 | { #category : #accessing } 35 | MLBFigureCommand >> dpi: anObject [ 36 | dpi := anObject 37 | ] 38 | 39 | { #category : #accessing } 40 | MLBFigureCommand >> edgecolor [ 41 | 42 | ^ edgecolor 43 | ] 44 | 45 | { #category : #accessing } 46 | MLBFigureCommand >> edgecolor: anObject [ 47 | edgecolor := anObject 48 | ] 49 | 50 | { #category : #accessing } 51 | MLBFigureCommand >> facecolor [ 52 | 53 | ^ facecolor 54 | ] 55 | 56 | { #category : #accessing } 57 | MLBFigureCommand >> facecolor: anObject [ 58 | facecolor := anObject 59 | ] 60 | 61 | { #category : #accessing } 62 | MLBFigureCommand >> figsize [ 63 | 64 | ^ figsize 65 | ] 66 | 67 | { #category : #accessing } 68 | MLBFigureCommand >> figsize: anObject [ 69 | figsize := anObject 70 | ] 71 | 72 | { #category : #accessing } 73 | MLBFigureCommand >> functionName [ 74 | ^ 'figure' 75 | ] 76 | 77 | { #category : #accessing } 78 | MLBFigureCommand >> num [ 79 | 80 | ^ num 81 | ] 82 | 83 | { #category : #accessing } 84 | MLBFigureCommand >> num: anObject [ 85 | num := anObject 86 | ] 87 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBAbstractAxis.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am the description of an abstract axis of a plot. 3 | 4 | I can generate the commands that allows to configure an axis for a plot. 5 | " 6 | Class { 7 | #name : #MLBAbstractAxis, 8 | #superclass : #MLBVisitableObject, 9 | #instVars : [ 10 | 'labels', 11 | 'labelsRotation', 12 | 'ticks', 13 | 'max', 14 | 'min', 15 | 'title', 16 | 'scale' 17 | ], 18 | #category : #'MatplotLibBridge-Model' 19 | } 20 | 21 | { #category : #initialization } 22 | MLBAbstractAxis >> initialize [ 23 | super initialize. 24 | self 25 | title: '' 26 | ] 27 | 28 | { #category : #accessing } 29 | MLBAbstractAxis >> labels [ 30 | ^ labels 31 | ] 32 | 33 | { #category : #accessing } 34 | MLBAbstractAxis >> labels: anObject [ 35 | labels := anObject 36 | ] 37 | 38 | { #category : #accessing } 39 | MLBAbstractAxis >> labelsRotation [ 40 | ^ labelsRotation 41 | ] 42 | 43 | { #category : #accessing } 44 | MLBAbstractAxis >> labelsRotation: anObject [ 45 | labelsRotation := anObject 46 | ] 47 | 48 | { #category : #scale } 49 | MLBAbstractAxis >> linearScale [ 50 | self scale: 'linear' asMLBScaleStyle 51 | ] 52 | 53 | { #category : #scale } 54 | MLBAbstractAxis >> logScale [ 55 | self scale: 'log' asMLBScaleStyle 56 | ] 57 | 58 | { #category : #scale } 59 | MLBAbstractAxis >> logitScale [ 60 | self scale: 'logit' asMLBScaleStyle 61 | ] 62 | 63 | { #category : #accessing } 64 | MLBAbstractAxis >> max [ 65 | ^ max 66 | ] 67 | 68 | { #category : #accessing } 69 | MLBAbstractAxis >> max: anObject [ 70 | max := anObject 71 | ] 72 | 73 | { #category : #accessing } 74 | MLBAbstractAxis >> min [ 75 | ^ min 76 | ] 77 | 78 | { #category : #accessing } 79 | MLBAbstractAxis >> min: anObject [ 80 | min := anObject 81 | ] 82 | 83 | { #category : #accessing } 84 | MLBAbstractAxis >> scale [ 85 | ^ scale 86 | ] 87 | 88 | { #category : #accessing } 89 | MLBAbstractAxis >> scale: anObject [ 90 | scale := anObject asMLBScaleStyle 91 | ] 92 | 93 | { #category : #scale } 94 | MLBAbstractAxis >> symlogScale [ 95 | self scale: 'symlog' asMLBScaleStyle 96 | ] 97 | 98 | { #category : #accessing } 99 | MLBAbstractAxis >> ticks [ 100 | ^ ticks 101 | ] 102 | 103 | { #category : #accessing } 104 | MLBAbstractAxis >> ticks: anObject [ 105 | ticks := anObject 106 | ] 107 | 108 | { #category : #accessing } 109 | MLBAbstractAxis >> title [ 110 | ^ title 111 | ] 112 | 113 | { #category : #accessing } 114 | MLBAbstractAxis >> title: anObject [ 115 | title := anObject 116 | ] 117 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBLine.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I represent an abstract 2-dimensions line. I am used by certain kind of plots (e.g. MLBLinePlot). 3 | " 4 | Class { 5 | #name : #MLBLine, 6 | #superclass : #MLBVisitableObject, 7 | #instVars : [ 8 | 'style', 9 | 'marker', 10 | 'color', 11 | 'label', 12 | 'width' 13 | ], 14 | #category : #'MatplotLibBridge-Model' 15 | } 16 | 17 | { #category : #'instance creation' } 18 | MLBLine class >> points: aListOfPoints [ 19 | ^ self new 20 | points: aListOfPoints; 21 | yourself 22 | ] 23 | 24 | { #category : #visiting } 25 | MLBLine >> acceptVisitor: visitor [ 26 | ^ visitor visitMLBLine: self 27 | ] 28 | 29 | { #category : #private } 30 | MLBLine >> alpha [ 31 | ^ self color alpha 32 | ] 33 | 34 | { #category : #accessing } 35 | MLBLine >> color [ 36 | ^ color 37 | ] 38 | 39 | { #category : #accessing } 40 | MLBLine >> color: anObject [ 41 | color := anObject 42 | ] 43 | 44 | { #category : #private } 45 | MLBLine >> colorHexString [ 46 | ^ '#' , self color asHexString 47 | ] 48 | 49 | { #category : #testing } 50 | MLBLine >> hasLabel [ 51 | ^ self label isNotNil 52 | ] 53 | 54 | { #category : #initialization } 55 | MLBLine >> initialize [ 56 | super initialize. 57 | self 58 | color: Color black; 59 | width: 1.0 60 | ] 61 | 62 | { #category : #testing } 63 | MLBLine >> isValidLineStyle: aString [ 64 | ^ self class isValidLineStyle: aString 65 | ] 66 | 67 | { #category : #testing } 68 | MLBLine >> isValidMarker: aString [ 69 | ^ self class isValidMarker: aString 70 | ] 71 | 72 | { #category : #accessing } 73 | MLBLine >> label [ 74 | ^ label 75 | ] 76 | 77 | { #category : #accessing } 78 | MLBLine >> label: anObject [ 79 | label := anObject 80 | ] 81 | 82 | { #category : #accessing } 83 | MLBLine >> marker [ 84 | ^ marker 85 | ] 86 | 87 | { #category : #accessing } 88 | MLBLine >> marker: anObject [ 89 | marker := anObject asMLBMarkerStyle 90 | ] 91 | 92 | { #category : #accessing } 93 | MLBLine >> style [ 94 | ^ style 95 | ] 96 | 97 | { #category : #accessing } 98 | MLBLine >> style: anObject [ 99 | style := anObject asMLBLineStyle 100 | ] 101 | 102 | { #category : #accessing } 103 | MLBLine >> width [ 104 | ^ width 105 | ] 106 | 107 | { #category : #accessing } 108 | MLBLine >> width: anObject [ 109 | width := anObject 110 | ] 111 | 112 | { #category : #private } 113 | MLBLine >> x [ 114 | ^ self subclassResponsibility 115 | ] 116 | 117 | { #category : #private } 118 | MLBLine >> y [ 119 | ^ self subclassResponsibility 120 | ] 121 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBLinePlot.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a high-level object to draw line plot from matplotlib. 3 | " 4 | Class { 5 | #name : #MLBLinePlot, 6 | #superclass : #MLBAbstractPlot, 7 | #instVars : [ 8 | 'lines', 9 | 'legend' 10 | ], 11 | #category : #'MatplotLibBridge-Model' 12 | } 13 | 14 | { #category : #example } 15 | MLBLinePlot class >> example [ 16 | MLBExamples exampleLineplot 17 | ] 18 | 19 | { #category : #example } 20 | MLBLinePlot class >> example2 [ 21 | MLBExamples exampleMultilineplot 22 | ] 23 | 24 | { #category : #example } 25 | MLBLinePlot class >> example3 [ 26 | MLBExamples exampleDiscontinuousLineplot 27 | ] 28 | 29 | { #category : #example } 30 | MLBLinePlot class >> example4 [ 31 | MLBExamples exampleChangingLineWidthOfLineplot 32 | ] 33 | 34 | { #category : #visiting } 35 | MLBLinePlot >> acceptVisitor: visitor [ 36 | ^ visitor visitMLBLinePlot: self 37 | ] 38 | 39 | { #category : #adding } 40 | MLBLinePlot >> addLegend [ 41 | self addLegend: [ :l| ] 42 | ] 43 | 44 | { #category : #adding } 45 | MLBLinePlot >> addLegend: aBlock [ 46 | self legend: MLBLegend new. 47 | aBlock value: self legend 48 | ] 49 | 50 | { #category : #deprecated } 51 | MLBLinePlot >> addLine: aBlock [ 52 | self 53 | deprecated: 'Please use #addPointsLine: instead' 54 | transformWith: '`@receiver addLine: `@statements' -> '`@receiver addPointsLine: `@statements'. 55 | self addPointsLine: aBlock 56 | ] 57 | 58 | { #category : #adding } 59 | MLBLinePlot >> addPointsLine: aBlock [ 60 | | line | 61 | line := MLBPointsLine new. 62 | aBlock value: line. 63 | self lines add: line 64 | ] 65 | 66 | { #category : #adding } 67 | MLBLinePlot >> addXBlockLine: aBlock [ 68 | | line | 69 | line := MLBXBlockLine new. 70 | aBlock value: line. 71 | self lines add: line 72 | ] 73 | 74 | { #category : #adding } 75 | MLBLinePlot >> addYBlockLine: aBlock [ 76 | | line | 77 | line := MLBYBlockLine new. 78 | aBlock value: line. 79 | self lines add: line 80 | ] 81 | 82 | { #category : #initialization } 83 | MLBLinePlot >> initialize [ 84 | super initialize. 85 | self 86 | lines: OrderedCollection new 87 | ] 88 | 89 | { #category : #accessing } 90 | MLBLinePlot >> legend [ 91 | ^ legend 92 | ] 93 | 94 | { #category : #accessing } 95 | MLBLinePlot >> legend: anObject [ 96 | legend := anObject 97 | ] 98 | 99 | { #category : #accessing } 100 | MLBLinePlot >> lines [ 101 | ^ lines 102 | ] 103 | 104 | { #category : #accessing } 105 | MLBLinePlot >> lines: anObject [ 106 | lines := anObject 107 | ] 108 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBAbstractVisitor.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am an abstract visitor. 3 | 4 | I describe the method to be implemented by my subclasses. 5 | " 6 | Class { 7 | #name : #MLBAbstractVisitor, 8 | #superclass : #Object, 9 | #category : #'MatplotLibBridge-Visitors' 10 | } 11 | 12 | { #category : #visiting } 13 | MLBAbstractVisitor >> visit: anObject [ 14 | ^ anObject acceptVisitor: self 15 | ] 16 | 17 | { #category : #visiting } 18 | MLBAbstractVisitor >> visitMLBAnnotation: aMLBAnnotation [ 19 | ^ self subclassResponsibility 20 | ] 21 | 22 | { #category : #visiting } 23 | MLBAbstractVisitor >> visitMLBBarPlot: aMLBBarPlot [ 24 | ^ self subclassResponsibility 25 | ] 26 | 27 | { #category : #visiting } 28 | MLBAbstractVisitor >> visitMLBBoxPlot: aMLBBoxPlot [ 29 | ^ self subclassResponsibility 30 | ] 31 | 32 | { #category : #visiting } 33 | MLBAbstractVisitor >> visitMLBLegend: aMLBLegend [ 34 | ^ self subclassResponsibility 35 | ] 36 | 37 | { #category : #visiting } 38 | MLBAbstractVisitor >> visitMLBLinePlot: aMLBLinePlot [ 39 | ^ self subclassResponsibility 40 | ] 41 | 42 | { #category : #visiting } 43 | MLBAbstractVisitor >> visitMLBPiePlot: aMLBPiePlot [ 44 | ^ self subclassResponsibility 45 | ] 46 | 47 | { #category : #visiting } 48 | MLBAbstractVisitor >> visitMLBPointsLine: aMLBPointsLine [ 49 | ^ self subclassResponsibility 50 | ] 51 | 52 | { #category : #visiting } 53 | MLBAbstractVisitor >> visitMLBScatterPlot2: aMLBScatterPlots [ 54 | ^ self subclassResponsibility 55 | ] 56 | 57 | { #category : #visiting } 58 | MLBAbstractVisitor >> visitMLBScatterPlot: aMLBScatterPlot [ 59 | ^ self subclassResponsibility 60 | ] 61 | 62 | { #category : #visiting } 63 | MLBAbstractVisitor >> visitMLBStackedBarPlot: aMLBStackedBarPlot [ 64 | ^ self subclassResponsibility 65 | ] 66 | 67 | { #category : #visiting } 68 | MLBAbstractVisitor >> visitMLBStyleSheet: aMLBStyleSheet [ 69 | ^ self subclassResponsibility 70 | ] 71 | 72 | { #category : #visiting } 73 | MLBAbstractVisitor >> visitMLBStyleSheetProperty: aMLBStyleSheetProperty [ 74 | ^ self subclassResponsibility 75 | ] 76 | 77 | { #category : #visiting } 78 | MLBAbstractVisitor >> visitMLBXAxis: aMLBXAxis [ 79 | ^ self subclassResponsibility 80 | ] 81 | 82 | { #category : #visiting } 83 | MLBAbstractVisitor >> visitMLBXBlockLine: aMLBXBlockLine [ 84 | ^ self subclassResponsibility 85 | ] 86 | 87 | { #category : #visiting } 88 | MLBAbstractVisitor >> visitMLBXKCDStyleSheet: aMLBXKCDStyleSheet [ 89 | ^ self subclassResponsibility 90 | ] 91 | 92 | { #category : #visiting } 93 | MLBAbstractVisitor >> visitMLBYAxis: aMLBYAxis [ 94 | ^ self subclassResponsibility 95 | ] 96 | 97 | { #category : #visiting } 98 | MLBAbstractVisitor >> visitMLBYBlockLine: aMLBYBlockLine [ 99 | ^ self subclassResponsibility 100 | ] 101 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am an abstract command. 3 | 4 | My subclasses need to set my #target inst var with the name of the target to apply the python function on. 5 | 6 | They may use the or pragma to define respectively: inst var that will be used as keyword arguments and inst var that will be used as positional arguments during the function call. The N argument of the pragma is the position of the argument. 7 | " 8 | Class { 9 | #name : #MLBCommand, 10 | #superclass : #Object, 11 | #instVars : [ 12 | 'module' 13 | ], 14 | #category : #'MatplotLibBridge-Commands-Core' 15 | } 16 | 17 | { #category : #comparing } 18 | MLBCommand >> = anObject [ 19 | "Answer whether the receiver and anObject represent the same object." 20 | 21 | self == anObject 22 | ifTrue: [ ^ true ]. 23 | self class = anObject class 24 | ifFalse: [ ^ false ]. 25 | ^ self module = anObject module 26 | and: [ self functionName = anObject functionName 27 | and: [ self mlbPositionalAttributes = anObject mlbPositionalAttributes 28 | and: [ self mlbAttributesDict = anObject mlbAttributesDict ] ] ] 29 | ] 30 | 31 | { #category : #execute } 32 | MLBCommand >> execute [ 33 | self generateInstructions execute 34 | ] 35 | 36 | { #category : #accessing } 37 | MLBCommand >> functionName [ 38 | ^ self subclassResponsibility 39 | ] 40 | 41 | { #category : #generating } 42 | MLBCommand >> generateInstructions [ 43 | ^ P3GInstructionsList new 44 | add: self module import; 45 | add: ((self module => self functionName) 46 | callWith: self mlbPositionalAttributes with: self mlbAttributesDict); 47 | yourself 48 | ] 49 | 50 | { #category : #comparing } 51 | MLBCommand >> hash [ 52 | "Answer an integer value that is related to the identity of the receiver." 53 | 54 | ^ ((module hash 55 | bitXor: self functionName hash) 56 | bitXor: self mlbPositionalAttributes hash) 57 | bitXor: self mlbAttributesDict hash 58 | ] 59 | 60 | { #category : #accessing } 61 | MLBCommand >> mlbAttributeAccessors [ 62 | ^ self mlbKeywordAttributePragmas collect: #methodSelector 63 | ] 64 | 65 | { #category : #accessing } 66 | MLBCommand >> mlbAttributesDict [ 67 | ^ (self mlbAttributeAccessors 68 | select: [ :selector | (selector value: self) isNotNil ] 69 | thenCollect: [ :selector | selector -> (selector value: self) ]) asDictionary 70 | ] 71 | 72 | { #category : #accessing } 73 | MLBCommand >> mlbKeywordAttributePragmas [ 74 | ^ Pragma allNamed: #mlbAttribute in: self class 75 | ] 76 | 77 | { #category : #accessing } 78 | MLBCommand >> mlbPositionalAttributePragmas [ 79 | ^ Pragma allNamed: #mlbAttribute: in: self class 80 | ] 81 | 82 | { #category : #accessing } 83 | MLBCommand >> mlbPositionalAttributes [ 84 | ^ ((self mlbPositionalAttributePragmas 85 | select: [ :p | (p methodSelector value: self) isNotNil ] 86 | thenCollect: [ :p | (p methodSelector value: self) -> p arguments first ]) 87 | sorted: [ :a :b | a value < b value ]) collect: #key 88 | ] 89 | 90 | { #category : #accessing } 91 | MLBCommand >> module [ 92 | ^ module 93 | ] 94 | 95 | { #category : #accessing } 96 | MLBCommand >> module: anObject [ 97 | module := anObject 98 | ] 99 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBCommandList.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a list of command to be executed. 3 | I ensure that the Python code is not too ugly (e.g. I avoid to import multiple time the same package). 4 | " 5 | Class { 6 | #name : #MLBCommandList, 7 | #superclass : #Object, 8 | #instVars : [ 9 | 'commands' 10 | ], 11 | #category : #'MatplotLibBridge-Commands-Core' 12 | } 13 | 14 | { #category : #comparing } 15 | MLBCommandList >> = anObject [ 16 | "Answer whether the receiver and anObject represent the same object." 17 | 18 | self == anObject 19 | ifTrue: [ ^ true ]. 20 | self class = anObject class 21 | ifFalse: [ ^ false ]. 22 | ^ self commands = anObject commands 23 | ] 24 | 25 | { #category : #adding } 26 | MLBCommandList >> add: aMLBCommand [ 27 | self commands add: aMLBCommand 28 | ] 29 | 30 | { #category : #adding } 31 | MLBCommandList >> addAll: aCollection [ 32 | self commands addAll: aCollection 33 | ] 34 | 35 | { #category : #accessing } 36 | MLBCommandList >> commands [ 37 | ^ commands 38 | ] 39 | 40 | { #category : #accessing } 41 | MLBCommandList >> commands: anObject [ 42 | commands := anObject 43 | ] 44 | 45 | { #category : #enumerating } 46 | MLBCommandList >> do: aBlock [ 47 | self commands do: aBlock 48 | ] 49 | 50 | { #category : #execute } 51 | MLBCommandList >> execute [ 52 | self generateInstructions execute 53 | ] 54 | 55 | { #category : #execute } 56 | MLBCommandList >> executeOptimized [ 57 | self optimizeGeneratedInstructions execute 58 | ] 59 | 60 | { #category : #generating } 61 | MLBCommandList >> generateInstructions [ 62 | "Returns the P3GInstructionsList resulting of the combinations of the 63 | commands I hold." 64 | | instructions | 65 | instructions := P3GInstructionsList new. 66 | self commands do: [ :command | 67 | command generateInstructions do: [ :inst | 68 | instructions add: inst ] ]. 69 | ^ instructions 70 | ] 71 | 72 | { #category : #comparing } 73 | MLBCommandList >> hash [ 74 | "Answer an integer value that is related to the identity of the receiver." 75 | 76 | ^ commands hash 77 | ] 78 | 79 | { #category : #initialization } 80 | MLBCommandList >> initialize [ 81 | super initialize. 82 | self commands: OrderedCollection new 83 | ] 84 | 85 | { #category : #optimizing } 86 | MLBCommandList >> optimizeGeneratedInstructions [ 87 | "Send #generateInstructions and modify the instructions so the whole set 88 | of instructions is optimized." 89 | | instructionsList | 90 | instructionsList := self generateInstructions. 91 | self 92 | removeDuplicatedImport: instructionsList; 93 | setImportInstructionsFirst: instructionsList. 94 | ^ instructionsList 95 | ] 96 | 97 | { #category : #removing } 98 | MLBCommandList >> remove: aMLBCommand [ 99 | self commands remove: aMLBCommand 100 | ] 101 | 102 | { #category : #optimizing } 103 | MLBCommandList >> removeDuplicatedImport: aP3GInstructionsList [ 104 | | alreadyImported newInstructions | 105 | alreadyImported := OrderedCollection new. 106 | newInstructions := OrderedCollection new. 107 | aP3GInstructionsList do: [ :inst | 108 | inst isImport 109 | ifTrue: [ 110 | |importCode| 111 | importCode := inst generate. 112 | (alreadyImported anySatisfy: [ :any | any generate = importCode ]) 113 | ifFalse: [ 114 | newInstructions add: inst. 115 | alreadyImported add: inst ] ] 116 | ifFalse: [ 117 | newInstructions add: inst ] ]. 118 | aP3GInstructionsList instructions: newInstructions 119 | ] 120 | 121 | { #category : #optimizing } 122 | MLBCommandList >> setImportInstructionsFirst: aP3GInstructionsList [ 123 | | weights | 124 | weights := Dictionary new. 125 | aP3GInstructionsList instructions doWithIndex: [ :instruction :index | 126 | instruction isImport 127 | ifTrue: [ weights at: instruction put: 0 ] 128 | ifFalse: [ weights at: instruction put: index ] ]. 129 | 130 | aP3GInstructionsList instructions sort: [ :a :b | 131 | (weights at: a) < (weights at: b) ] 132 | 133 | 134 | ] 135 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBAbstractPlot.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a high-level abstract object to draw plot from matplotlib. 3 | 4 | I define methods common to all plot object. 5 | 6 | You do not have to bother with Python code at all when using my subclasses. In fact it is my purpose to avoid you learning Python to be able to use them! 7 | " 8 | Class { 9 | #name : #MLBAbstractPlot, 10 | #superclass : #MLBVisitableObject, 11 | #instVars : [ 12 | 'title', 13 | 'titleFontDict', 14 | 'titleLocation', 15 | 'xAxis', 16 | 'yAxis', 17 | 'style', 18 | 'annotations', 19 | 'axis', 20 | 'gridOnAxis', 21 | 'xAxisTwin', 22 | 'yAxisTwin' 23 | ], 24 | #category : #'MatplotLibBridge-Model' 25 | } 26 | 27 | { #category : #visiting } 28 | MLBAbstractPlot >> acceptVisitor: visitor [ 29 | ^ self subclassResponsibility 30 | ] 31 | 32 | { #category : #annotations } 33 | MLBAbstractPlot >> addAnnotation: aBlock [ 34 | | annotation | 35 | annotation := MLBAnnotation new. 36 | aBlock value: annotation. 37 | self annotations add: annotation 38 | ] 39 | 40 | { #category : #accessing } 41 | MLBAbstractPlot >> annotations [ 42 | ^ annotations 43 | ] 44 | 45 | { #category : #accessing } 46 | MLBAbstractPlot >> annotations: anObject [ 47 | annotations := anObject 48 | ] 49 | 50 | { #category : #accessing } 51 | MLBAbstractPlot >> axis [ 52 | ^ axis 53 | ] 54 | 55 | { #category : #accessing } 56 | MLBAbstractPlot >> axis: anObject [ 57 | axis := anObject 58 | ] 59 | 60 | { #category : #'axis configuration' } 61 | MLBAbstractPlot >> configXAxis: aBlock [ 62 | aBlock value: self xAxis 63 | ] 64 | 65 | { #category : #'axis configuration' } 66 | MLBAbstractPlot >> configYAxis: aBlock [ 67 | aBlock value: self yAxis 68 | ] 69 | 70 | { #category : #'axis configuration' } 71 | MLBAbstractPlot >> createXAxisTwin: configurationBlock [ 72 | self xAxisTwin: self xAxis copy. 73 | configurationBlock value: self xAxisTwin 74 | ] 75 | 76 | { #category : #'axis configuration' } 77 | MLBAbstractPlot >> createYAxisTwin: configurationBlock [ 78 | self yAxisTwin: self yAxis copy. 79 | configurationBlock value: self yAxisTwin 80 | ] 81 | 82 | { #category : #accessing } 83 | MLBAbstractPlot >> gridOnAxis [ 84 | ^ gridOnAxis 85 | ] 86 | 87 | { #category : #accessing } 88 | MLBAbstractPlot >> gridOnAxis: anObject [ 89 | gridOnAxis := anObject asMLBGridStyle 90 | ] 91 | 92 | { #category : #testing } 93 | MLBAbstractPlot >> hasXAxisTwin [ 94 | ^ self xAxisTwin isNotNil 95 | ] 96 | 97 | { #category : #testing } 98 | MLBAbstractPlot >> hasYAxisTwin [ 99 | ^ self yAxisTwin isNotNil 100 | ] 101 | 102 | { #category : #initialization } 103 | MLBAbstractPlot >> initialize [ 104 | super initialize. 105 | self 106 | title: ''; 107 | annotations: OrderedCollection new; 108 | xAxis: MLBXAxis new; 109 | yAxis: MLBYAxis new 110 | ] 111 | 112 | { #category : #grid } 113 | MLBAbstractPlot >> showGrid [ 114 | self gridOnAxis: 'both' asMLBGridStyle 115 | ] 116 | 117 | { #category : #grid } 118 | MLBAbstractPlot >> showXGrid [ 119 | self gridOnAxis: 'x' asMLBGridStyle 120 | ] 121 | 122 | { #category : #grid } 123 | MLBAbstractPlot >> showYGrid [ 124 | self gridOnAxis: 'y' asMLBGridStyle 125 | ] 126 | 127 | { #category : #accessing } 128 | MLBAbstractPlot >> style [ 129 | ^ style 130 | ] 131 | 132 | { #category : #accessing } 133 | MLBAbstractPlot >> style: anObject [ 134 | style := anObject 135 | ] 136 | 137 | { #category : #accessing } 138 | MLBAbstractPlot >> title [ 139 | ^ title 140 | ] 141 | 142 | { #category : #accessing } 143 | MLBAbstractPlot >> title: anObject [ 144 | title := anObject 145 | ] 146 | 147 | { #category : #accessing } 148 | MLBAbstractPlot >> titleFontDict [ 149 | ^ titleFontDict 150 | ] 151 | 152 | { #category : #accessing } 153 | MLBAbstractPlot >> titleFontDict: anObject [ 154 | titleFontDict := anObject 155 | ] 156 | 157 | { #category : #accessing } 158 | MLBAbstractPlot >> titleLocation [ 159 | ^ titleLocation 160 | ] 161 | 162 | { #category : #accessing } 163 | MLBAbstractPlot >> titleLocation: anObject [ 164 | titleLocation := anObject 165 | ] 166 | 167 | { #category : #accessing } 168 | MLBAbstractPlot >> xAxis [ 169 | ^ xAxis 170 | ] 171 | 172 | { #category : #accessing } 173 | MLBAbstractPlot >> xAxis: anObject [ 174 | xAxis := anObject 175 | ] 176 | 177 | { #category : #accessing } 178 | MLBAbstractPlot >> xAxisTwin [ 179 | ^ xAxisTwin 180 | ] 181 | 182 | { #category : #accessing } 183 | MLBAbstractPlot >> xAxisTwin: anObject [ 184 | xAxisTwin := anObject 185 | ] 186 | 187 | { #category : #styling } 188 | MLBAbstractPlot >> xkcdStyle [ 189 | self style: MLBXKCDStyleSheet new 190 | ] 191 | 192 | { #category : #accessing } 193 | MLBAbstractPlot >> yAxis [ 194 | ^ yAxis 195 | ] 196 | 197 | { #category : #accessing } 198 | MLBAbstractPlot >> yAxis: anObject [ 199 | yAxis := anObject 200 | ] 201 | 202 | { #category : #accessing } 203 | MLBAbstractPlot >> yAxisTwin [ 204 | ^ yAxisTwin 205 | ] 206 | 207 | { #category : #accessing } 208 | MLBAbstractPlot >> yAxisTwin: anObject [ 209 | yAxisTwin := anObject 210 | ] 211 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBScatterCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.scatter function. 3 | 4 | I have the following attributes as described in matplotlib doc: 5 | -x, y : array 6 | Input data 7 | 8 | -s : scalar or array_like, shape (n, ), optional, default: 20 9 | size in points^2. 10 | 11 | -c : color, sequence, or sequence of color, optional, default: ‘b’ 12 | c can be a single color format string, or a sequence of color specifications of length N, or a sequence of N numbers to be mapped to colors using the cmap and norm specified via kwargs (see below). Note that c should not be a single numeric RGB or RGBA sequence because that is indistinguishable from an array of values to be colormapped. c can be a 2-D array in which the rows are RGB or RGBA, however, including the case of a single row to specify the same color for all points. 13 | 14 | -marker : MarkerStyle, optional, default: ‘o’ 15 | See markers for more information on the different styles of markers scatter supports. marker can be either an instance of the class or the text shorthand for a particular marker. 16 | 17 | -cmap : Colormap, optional, default: None 18 | A Colormap instance or registered name. cmap is only used if c is an array of floats. If None, defaults to rc image.cmap. 19 | 20 | -norm : Normalize, optional, default: None 21 | A Normalize instance is used to scale luminance data to 0, 1. norm is only used if c is an array of floats. If None, use the default normalize(). 22 | 23 | -vmin, vmax : scalar, optional, default: None 24 | vmin and vmax are used in conjunction with norm to normalize luminance data. If either are None, the min and max of the color array is used. Note if you pass a norm instance, your settings for vmin and vmax will be ignored. 25 | 26 | -alpha : scalar, optional, default: None 27 | The alpha blending value, between 0 (transparent) and 1 (opaque) 28 | 29 | -linewidths : scalar or array_like, optional, default: None 30 | If None, defaults to (lines.linewidth,). 31 | 32 | -edgecolors : color or sequence of color, optional, default: None 33 | If None, defaults to (patch.edgecolor). If ‘face’, the edge color will always be the same as the face color. If it is ‘none’, the patch boundary will not be drawn. For non-filled markers, the edgecolors kwarg is ignored; color is determined by c. 34 | " 35 | Class { 36 | #name : #MLBScatterCommand, 37 | #superclass : #MLBPyplotCommand, 38 | #instVars : [ 39 | 'x', 40 | 'y', 41 | 's', 42 | 'c', 43 | 'marker', 44 | 'cmap', 45 | 'norm', 46 | 'vmin', 47 | 'vmax', 48 | 'alpha', 49 | 'linewidths', 50 | 'edgecolors' 51 | ], 52 | #category : #'MatplotLibBridge-Commands-Core' 53 | } 54 | 55 | { #category : #accessing } 56 | MLBScatterCommand >> alpha [ 57 | 58 | ^ alpha 59 | ] 60 | 61 | { #category : #accessing } 62 | MLBScatterCommand >> alpha: anObject [ 63 | alpha := anObject 64 | ] 65 | 66 | { #category : #accessing } 67 | MLBScatterCommand >> c [ 68 | 69 | ^ c 70 | ] 71 | 72 | { #category : #accessing } 73 | MLBScatterCommand >> c: anObject [ 74 | c := anObject 75 | ] 76 | 77 | { #category : #accessing } 78 | MLBScatterCommand >> cmap [ 79 | 80 | ^ cmap 81 | ] 82 | 83 | { #category : #accessing } 84 | MLBScatterCommand >> cmap: anObject [ 85 | cmap := anObject 86 | ] 87 | 88 | { #category : #accessing } 89 | MLBScatterCommand >> edgecolors [ 90 | 91 | ^ edgecolors 92 | ] 93 | 94 | { #category : #accessing } 95 | MLBScatterCommand >> edgecolors: anObject [ 96 | edgecolors := anObject 97 | ] 98 | 99 | { #category : #accessing } 100 | MLBScatterCommand >> functionName [ 101 | ^ 'scatter' 102 | ] 103 | 104 | { #category : #accessing } 105 | MLBScatterCommand >> linewidths [ 106 | 107 | ^ linewidths 108 | ] 109 | 110 | { #category : #accessing } 111 | MLBScatterCommand >> linewidths: anObject [ 112 | linewidths := anObject 113 | ] 114 | 115 | { #category : #accessing } 116 | MLBScatterCommand >> marker [ 117 | 118 | ^ marker 119 | ] 120 | 121 | { #category : #accessing } 122 | MLBScatterCommand >> marker: anObject [ 123 | marker := anObject 124 | ] 125 | 126 | { #category : #accessing } 127 | MLBScatterCommand >> norm [ 128 | 129 | ^ norm 130 | ] 131 | 132 | { #category : #accessing } 133 | MLBScatterCommand >> norm: anObject [ 134 | norm := anObject 135 | ] 136 | 137 | { #category : #accessing } 138 | MLBScatterCommand >> s [ 139 | 140 | ^ s 141 | ] 142 | 143 | { #category : #accessing } 144 | MLBScatterCommand >> s: anObject [ 145 | s := anObject 146 | ] 147 | 148 | { #category : #accessing } 149 | MLBScatterCommand >> vmax [ 150 | 151 | ^ vmax 152 | ] 153 | 154 | { #category : #accessing } 155 | MLBScatterCommand >> vmax: anObject [ 156 | vmax := anObject 157 | ] 158 | 159 | { #category : #accessing } 160 | MLBScatterCommand >> vmin [ 161 | 162 | ^ vmin 163 | ] 164 | 165 | { #category : #accessing } 166 | MLBScatterCommand >> vmin: anObject [ 167 | vmin := anObject 168 | ] 169 | 170 | { #category : #accessing } 171 | MLBScatterCommand >> x [ 172 | 173 | ^ x 174 | ] 175 | 176 | { #category : #accessing } 177 | MLBScatterCommand >> x: anObject [ 178 | x := anObject 179 | ] 180 | 181 | { #category : #accessing } 182 | MLBScatterCommand >> y [ 183 | 184 | ^ y 185 | ] 186 | 187 | { #category : #accessing } 188 | MLBScatterCommand >> y: anObject [ 189 | y := anObject 190 | ] 191 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBSaveFigCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.savefig function. 3 | 4 | From the doc, I am configured with: 5 | 6 | -filename (required!): 7 | A string containing a path to a filename, or a Python file-like object, or possibly some backend-dependent object such as PdfPages. 8 | If format is None and fname is a string, the output format is deduced from the extension of the filename. If the filename has no extension, the value of the rc parameter savefig.format is used. 9 | If fname is not a string, remember to specify format to ensure that the correct backend is used. 10 | 11 | -dpi: [ None | scalar > 0 | ‘figure’] 12 | The resolution in dots per inch. If None it will default to the value savefig.dpi in the matplotlibrc file. If ‘figure’ it will set the dpi to be the value of the figure. 13 | 14 | -facecolor, edgecolor: 15 | the colors of the figure rectangle 16 | orientation: [ ‘landscape’ | ‘portrait’ ] 17 | not supported on all backends; currently only on postscript output 18 | 19 | -papertype: 20 | One of ‘letter’, ‘legal’, ‘executive’, ‘ledger’, ‘a0’ through ‘a10’, ‘b0’ through ‘b10’. Only supported for postscript output. 21 | 22 | -format: 23 | One of the file extensions supported by the active backend. Most backends support png, pdf, ps, eps and svg. 24 | 25 | -transparent: 26 | If True, the axes patches will all be transparent; the figure patch will also be transparent unless facecolor and/or edgecolor are specified via kwargs. This is useful, for example, for displaying a plot on top of a colored background on a web page. The transparency of these patches will be restored to their original values upon exit of this function. 27 | 28 | -frameon: 29 | If True, the figure patch will be colored, if False, the figure background will be transparent. If not provided, the rcParam ‘savefig.frameon’ will be used. 30 | 31 | -bbox_inches: 32 | Bbox in inches. Only the given portion of the figure is saved. If ‘tight’, try to figure out the tight bbox of the figure. 33 | 34 | -pad_inches: 35 | Amount of padding around the figure when bbox_inches is ‘tight’. 36 | bbox_extra_artists: 37 | A list of extra artists that will be considered when the tight bbox is calculated. 38 | " 39 | Class { 40 | #name : #MLBSaveFigCommand, 41 | #superclass : #MLBPyplotCommand, 42 | #instVars : [ 43 | 'dpi', 44 | 'facecolor', 45 | 'edgecolor', 46 | 'papertype', 47 | 'format', 48 | 'transparent', 49 | 'frameon', 50 | 'bbox_inches', 51 | 'pad_inches', 52 | 'fname' 53 | ], 54 | #category : #'MatplotLibBridge-Commands-Core' 55 | } 56 | 57 | { #category : #accessing } 58 | MLBSaveFigCommand >> bbox_inches [ 59 | 60 | ^ bbox_inches 61 | ] 62 | 63 | { #category : #accessing } 64 | MLBSaveFigCommand >> bbox_inches: anObject [ 65 | bbox_inches := anObject 66 | ] 67 | 68 | { #category : #accessing } 69 | MLBSaveFigCommand >> dpi [ 70 | 71 | ^ dpi 72 | ] 73 | 74 | { #category : #accessing } 75 | MLBSaveFigCommand >> dpi: anObject [ 76 | dpi := anObject 77 | ] 78 | 79 | { #category : #accessing } 80 | MLBSaveFigCommand >> edgecolor [ 81 | 82 | ^ edgecolor 83 | ] 84 | 85 | { #category : #accessing } 86 | MLBSaveFigCommand >> edgecolor: anObject [ 87 | edgecolor := anObject 88 | ] 89 | 90 | { #category : #accessing } 91 | MLBSaveFigCommand >> facecolor [ 92 | 93 | ^ facecolor 94 | ] 95 | 96 | { #category : #accessing } 97 | MLBSaveFigCommand >> facecolor: anObject [ 98 | facecolor := anObject 99 | ] 100 | 101 | { #category : #accessing } 102 | MLBSaveFigCommand >> filename [ 103 | "The argument has been renamed fname, this method is here for retro-compatibility purpose." 104 | ^ self fname 105 | ] 106 | 107 | { #category : #accessing } 108 | MLBSaveFigCommand >> filename: anObject [ 109 | "The argument has been renamed fname, this method is here for retro-compatibility purpose." 110 | self fname: anObject 111 | ] 112 | 113 | { #category : #accessing } 114 | MLBSaveFigCommand >> fname [ 115 | 116 | ^ fname 117 | ] 118 | 119 | { #category : #accessing } 120 | MLBSaveFigCommand >> fname: anObject [ 121 | fname := anObject 122 | ] 123 | 124 | { #category : #accessing } 125 | MLBSaveFigCommand >> format [ 126 | 127 | ^ format 128 | ] 129 | 130 | { #category : #accessing } 131 | MLBSaveFigCommand >> format: anObject [ 132 | format := anObject 133 | ] 134 | 135 | { #category : #accessing } 136 | MLBSaveFigCommand >> frameon [ 137 | 138 | ^ frameon 139 | ] 140 | 141 | { #category : #accessing } 142 | MLBSaveFigCommand >> frameon: anObject [ 143 | frameon := anObject 144 | ] 145 | 146 | { #category : #accessing } 147 | MLBSaveFigCommand >> functionName [ 148 | ^ 'savefig' 149 | ] 150 | 151 | { #category : #accessing } 152 | MLBSaveFigCommand >> pad_inches [ 153 | 154 | ^ pad_inches 155 | ] 156 | 157 | { #category : #accessing } 158 | MLBSaveFigCommand >> pad_inches: anObject [ 159 | pad_inches := anObject 160 | ] 161 | 162 | { #category : #accessing } 163 | MLBSaveFigCommand >> papertype [ 164 | 165 | ^ papertype 166 | ] 167 | 168 | { #category : #accessing } 169 | MLBSaveFigCommand >> papertype: anObject [ 170 | papertype := anObject 171 | ] 172 | 173 | { #category : #accessing } 174 | MLBSaveFigCommand >> transparent [ 175 | 176 | ^ transparent 177 | ] 178 | 179 | { #category : #accessing } 180 | MLBSaveFigCommand >> transparent: anObject [ 181 | transparent := anObject 182 | ] 183 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBAnnotateCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.annotate function. 3 | 4 | - s : str 5 | 6 | The text of the annotation 7 | 8 | - xy : iterable 9 | 10 | Length 2 sequence specifying the (x,y) point to annotate 11 | 12 | - xytext : iterable, optional 13 | 14 | Length 2 sequence specifying the (x,y) to place the text at. If None, defaults to xy. 15 | 16 | - xycoords : str, Artist, Transform, callable or tuple, optional 17 | 18 | The coordinate system that xy is given in. 19 | 20 | For a str the allowed values are: 21 | 22 | Property Description 23 | ‘figure points’ points from the lower left of the figure 24 | ‘figure pixels’ pixels from the lower left of the figure 25 | ‘figure fraction’ fraction of figure from lower left 26 | ‘axes points’ points from lower left corner of axes 27 | ‘axes pixels’ pixels from lower left corner of axes 28 | ‘axes fraction’ fraction of axes from lower left 29 | ‘data’ use the coordinate system of the object being annotated (default) 30 | ‘polar’ (theta,r) if not native ‘data’ coordinates 31 | If a Artist object is passed in the units are fraction if it’s bounding box. 32 | 33 | If a Transform object is passed in use that to transform xy to screen coordinates 34 | 35 | If a callable it must take a RendererBase object as input and return a Transform or Bbox object 36 | 37 | If a tuple must be length 2 tuple of str, Artist, Transform or callable objects. The first transform is used for the x coordinate and the second for y. 38 | 39 | See Advanced Annotation for more details. 40 | 41 | Defaults to 'data' 42 | 43 | - textcoords : str, Artist, Transform, callable or tuple, optional 44 | 45 | The coordinate system that xytext is given, which may be different than the coordinate system used for xy. 46 | 47 | All xycoords values are valid as well as the following strings: 48 | 49 | Property Description 50 | ‘offset points’ offset (in points) from the xy value 51 | ‘offset pixels’ offset (in pixels) from the xy value 52 | defaults to the input of xycoords 53 | 54 | - arrowprops : dict, optional 55 | 56 | If not None, properties used to draw a FancyArrowPatch arrow between xy and xytext. 57 | 58 | If arrowprops does not contain the key 'arrowstyle' the allowed keys are: 59 | 60 | Key Description 61 | width the width of the arrow in points 62 | headwidth the width of the base of the arrow head in points 63 | headlength the length of the arrow head in points 64 | shrink fraction of total length to ‘shrink’ from both ends 65 | ? any key to matplotlib.patches.FancyArrowPatch 66 | If the arrowprops contains the key 'arrowstyle' the above keys are forbidden. The allowed values of 'arrowstyle' are: 67 | 68 | Name Attrs 69 | '-' None 70 | '->' head_length=0.4,head_width=0.2 71 | '-[' widthB=1.0,lengthB=0.2,angleB=None 72 | '|-|' widthA=1.0,widthB=1.0 73 | '-|>' head_length=0.4,head_width=0.2 74 | '<-' head_length=0.4,head_width=0.2 75 | '<->' head_length=0.4,head_width=0.2 76 | '<|-' head_length=0.4,head_width=0.2 77 | '<|-|>' head_length=0.4,head_width=0.2 78 | 'fancy' head_length=0.4,head_width=0.4,tail_width=0.4 79 | 'simple' head_length=0.5,head_width=0.5,tail_width=0.2 80 | 'wedge' tail_width=0.3,shrink_factor=0.5 81 | Valid keys for FancyArrowPatch are: 82 | 83 | Key Description 84 | arrowstyle the arrow style 85 | connectionstyle the connection style 86 | relpos default is (0.5, 0.5) 87 | patchA default is bounding box of the text 88 | patchB default is None 89 | shrinkA default is 2 points 90 | shrinkB default is 2 points 91 | mutation_scale default is text size (in points) 92 | mutation_aspect default is 1. 93 | ? any key for matplotlib.patches.PathPatch 94 | Defaults to None 95 | 96 | - annotation_clip : bool, optional 97 | 98 | Controls the visibility of the annotation when it goes outside the axes area. 99 | 100 | If True, the annotation will only be drawn when the xy is inside the axes. If False, the annotation will always be drawn regardless of its position. 101 | 102 | The default is None, which behave as True only if xycoords is “data”. 103 | " 104 | Class { 105 | #name : #MLBAnnotateCommand, 106 | #superclass : #MLBPyplotCommand, 107 | #instVars : [ 108 | 's', 109 | 'xy', 110 | 'xytext', 111 | 'xycoords', 112 | 'textcoords', 113 | 'arrowprops', 114 | 'annotation_clip' 115 | ], 116 | #category : #'MatplotLibBridge-Commands-Core' 117 | } 118 | 119 | { #category : #accessing } 120 | MLBAnnotateCommand >> annotation_clip [ 121 | 122 | ^ annotation_clip 123 | ] 124 | 125 | { #category : #accessing } 126 | MLBAnnotateCommand >> annotation_clip: anObject [ 127 | annotation_clip := anObject 128 | ] 129 | 130 | { #category : #accessing } 131 | MLBAnnotateCommand >> arrowprops [ 132 | 133 | ^ arrowprops 134 | ] 135 | 136 | { #category : #accessing } 137 | MLBAnnotateCommand >> arrowprops: anObject [ 138 | arrowprops := anObject 139 | ] 140 | 141 | { #category : #accessing } 142 | MLBAnnotateCommand >> functionName [ 143 | ^ 'annotate' 144 | ] 145 | 146 | { #category : #accessing } 147 | MLBAnnotateCommand >> s [ 148 | 149 | ^ s 150 | ] 151 | 152 | { #category : #accessing } 153 | MLBAnnotateCommand >> s: anObject [ 154 | s := anObject 155 | ] 156 | 157 | { #category : #accessing } 158 | MLBAnnotateCommand >> textcoords [ 159 | 160 | ^ textcoords 161 | ] 162 | 163 | { #category : #accessing } 164 | MLBAnnotateCommand >> textcoords: anObject [ 165 | textcoords := anObject 166 | ] 167 | 168 | { #category : #accessing } 169 | MLBAnnotateCommand >> xy [ 170 | 171 | ^ xy 172 | ] 173 | 174 | { #category : #accessing } 175 | MLBAnnotateCommand >> xy: anObject [ 176 | xy := anObject 177 | ] 178 | 179 | { #category : #accessing } 180 | MLBAnnotateCommand >> xycoords [ 181 | 182 | ^ xycoords 183 | ] 184 | 185 | { #category : #accessing } 186 | MLBAnnotateCommand >> xycoords: anObject [ 187 | xycoords := anObject 188 | ] 189 | 190 | { #category : #accessing } 191 | MLBAnnotateCommand >> xytext [ 192 | 193 | ^ xytext 194 | ] 195 | 196 | { #category : #accessing } 197 | MLBAnnotateCommand >> xytext: anObject [ 198 | xytext := anObject 199 | ] 200 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBBarCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.bar function. 3 | 4 | I have the following attributes as described in matplotlib doc: 5 | -left : sequence of scalars: the x coordinates of the left sides of the bars 6 | -height : sequence of scalars the heights of the bars 7 | -width : scalar or array-like, optional the width(s) of the bars default: 0.8 8 | -bottom : scalar or array-like, optional the y coordinate(s) of the bars default: None 9 | -color : scalar or array-like, optional the colors of the bar faces 10 | -edgecolor : scalar or array-like, optional the colors of the bar edges 11 | -linewidth : scalar or array-like, optional width of bar edge(s). If None, use default linewidth; If 0, don’t draw edges. default: None 12 | -tick_label : string or array-like, optional the tick labels of the bars default: None 13 | -xerr : scalar or array-like, optional if not None, will be used to generate errorbar(s) on the bar chart default: None 14 | -yerr : scalar or array-like, optional if not None, will be used to generate errorbar(s) on the bar chart default: None 15 | -ecolor : scalar or array-like, optional specifies the color of errorbar(s) default: None 16 | -capsize : scalar, optional determines the length in points of the error bar caps default: None, which will take the value from the errorbar.capsize rcParam. 17 | -error_kw : dict, optional dictionary of kwargs to be passed to errorbar method. ecolor and capsize may be specified here rather than as independent kwargs. 18 | -align : {‘edge’, ‘center’}, optional If ‘edge’, aligns bars by their left edges (for vertical bars) and by their bottom edges (for horizontal bars). If ‘center’, interpret the left argument as the coordinates of the centers of the bars. To align on the align bars on the right edge pass a negative width. 19 | -orientation : {‘vertical’, ‘horizontal’}, optional The orientation of the bars. 20 | -log : boolean, optional If true, sets the axis to be log scale. default: False 21 | " 22 | Class { 23 | #name : #MLBBarCommand, 24 | #superclass : #MLBPyplotCommand, 25 | #instVars : [ 26 | 'height', 27 | 'width', 28 | 'bottom', 29 | 'color', 30 | 'edgecolor', 31 | 'linewidth', 32 | 'tick_label', 33 | 'xerr', 34 | 'yerr', 35 | 'ecolor', 36 | 'capsize', 37 | 'error_kw', 38 | 'align', 39 | 'orientation', 40 | 'log', 41 | 'x' 42 | ], 43 | #category : #'MatplotLibBridge-Commands-Core' 44 | } 45 | 46 | { #category : #accessing } 47 | MLBBarCommand >> align [ 48 | 49 | ^ align 50 | ] 51 | 52 | { #category : #accessing } 53 | MLBBarCommand >> align: anObject [ 54 | align := anObject 55 | ] 56 | 57 | { #category : #accessing } 58 | MLBBarCommand >> block [ 59 | 60 | ^ capsize 61 | ] 62 | 63 | { #category : #accessing } 64 | MLBBarCommand >> bottom [ 65 | 66 | ^ bottom 67 | ] 68 | 69 | { #category : #accessing } 70 | MLBBarCommand >> bottom: anObject [ 71 | bottom := anObject 72 | ] 73 | 74 | { #category : #accessing } 75 | MLBBarCommand >> capsize: anObject [ 76 | capsize := anObject 77 | ] 78 | 79 | { #category : #accessing } 80 | MLBBarCommand >> color [ 81 | 82 | ^ color 83 | ] 84 | 85 | { #category : #accessing } 86 | MLBBarCommand >> color: anObject [ 87 | color := anObject 88 | ] 89 | 90 | { #category : #accessing } 91 | MLBBarCommand >> ecolor [ 92 | 93 | ^ ecolor 94 | ] 95 | 96 | { #category : #accessing } 97 | MLBBarCommand >> ecolor: anObject [ 98 | ecolor := anObject 99 | ] 100 | 101 | { #category : #accessing } 102 | MLBBarCommand >> edgecolor [ 103 | 104 | ^ edgecolor 105 | ] 106 | 107 | { #category : #accessing } 108 | MLBBarCommand >> edgecolor: anObject [ 109 | edgecolor := anObject 110 | ] 111 | 112 | { #category : #accessing } 113 | MLBBarCommand >> error_kw [ 114 | 115 | ^ error_kw 116 | ] 117 | 118 | { #category : #accessing } 119 | MLBBarCommand >> error_kw: anObject [ 120 | error_kw := anObject 121 | ] 122 | 123 | { #category : #accessing } 124 | MLBBarCommand >> functionName [ 125 | ^ 'bar' 126 | ] 127 | 128 | { #category : #accessing } 129 | MLBBarCommand >> height [ 130 | 131 | ^ height 132 | ] 133 | 134 | { #category : #accessing } 135 | MLBBarCommand >> height: anObject [ 136 | height := anObject 137 | ] 138 | 139 | { #category : #accessing } 140 | MLBBarCommand >> left [ 141 | "The argument has been renamed x, this method is here for retro-compatibility purpose." 142 | ^ self x 143 | ] 144 | 145 | { #category : #accessing } 146 | MLBBarCommand >> left: anObject [ 147 | "The argument has been renamed x, this method is here for retro-compatibility purpose." 148 | self x: anObject 149 | ] 150 | 151 | { #category : #accessing } 152 | MLBBarCommand >> linewidth [ 153 | 154 | ^ linewidth 155 | ] 156 | 157 | { #category : #accessing } 158 | MLBBarCommand >> linewidth: anObject [ 159 | linewidth := anObject 160 | ] 161 | 162 | { #category : #accessing } 163 | MLBBarCommand >> log [ 164 | 165 | ^ log 166 | ] 167 | 168 | { #category : #accessing } 169 | MLBBarCommand >> log: anObject [ 170 | log := anObject 171 | ] 172 | 173 | { #category : #accessing } 174 | MLBBarCommand >> orientation [ 175 | 176 | ^ orientation 177 | ] 178 | 179 | { #category : #accessing } 180 | MLBBarCommand >> orientation: anObject [ 181 | orientation := anObject 182 | ] 183 | 184 | { #category : #accessing } 185 | MLBBarCommand >> tick_label [ 186 | 187 | ^ tick_label 188 | ] 189 | 190 | { #category : #accessing } 191 | MLBBarCommand >> tick_label: anObject [ 192 | tick_label := anObject 193 | ] 194 | 195 | { #category : #accessing } 196 | MLBBarCommand >> width [ 197 | 198 | ^ width 199 | ] 200 | 201 | { #category : #accessing } 202 | MLBBarCommand >> width: anObject [ 203 | width := anObject 204 | ] 205 | 206 | { #category : #accessing } 207 | MLBBarCommand >> x [ 208 | 209 | ^ x 210 | ] 211 | 212 | { #category : #accessing } 213 | MLBBarCommand >> x: anObject [ 214 | x := anObject 215 | ] 216 | 217 | { #category : #accessing } 218 | MLBBarCommand >> xerr [ 219 | 220 | ^ xerr 221 | ] 222 | 223 | { #category : #accessing } 224 | MLBBarCommand >> xerr: anObject [ 225 | xerr := anObject 226 | ] 227 | 228 | { #category : #accessing } 229 | MLBBarCommand >> yerr [ 230 | 231 | ^ yerr 232 | ] 233 | 234 | { #category : #accessing } 235 | MLBBarCommand >> yerr: anObject [ 236 | yerr := anObject 237 | ] 238 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBPieCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.pie function. 3 | 4 | From the doc, I can be configured with: 5 | - x : array-like 6 | 7 | The input array used to make the pie chart. 8 | 9 | - explode : array-like, optional, default: None 10 | 11 | If not None, is a len(x) array which specifies the fraction of the radius with which to offset each wedge. 12 | 13 | - labels : list, optional, default: None 14 | 15 | A sequence of strings providing the labels for each wedge 16 | 17 | - colors : array-like, optional, default: None 18 | 19 | A sequence of matplotlib color args through which the pie chart will cycle. If None, will use the colors in the currently active cycle. 20 | 21 | - autopct : None (default), string, or function, optional 22 | 23 | If not None, is a string or function used to label the wedges with their numeric value. The label will be placed inside the wedge. If it is a format string, the label will be fmt%pct. If it is a function, it will be called. 24 | 25 | - pctdistance : float, optional, default: 0.6 26 | 27 | The ratio between the center of each pie slice and the start of the text generated by autopct. Ignored if autopct is None. 28 | 29 | - shadow : bool, optional, default: False 30 | 31 | Draw a shadow beneath the pie. 32 | 33 | - labeldistance : float, optional, default: 1.1 34 | 35 | The radial distance at which the pie labels are drawn 36 | 37 | - startangle : float, optional, default: None 38 | 39 | If not None, rotates the start of the pie chart by angle degrees counterclockwise from the x-axis. 40 | 41 | - radius : float, optional, default: None 42 | 43 | The radius of the pie, if radius is None it will be set to 1. 44 | 45 | - counterclock : bool, optional, default: True 46 | 47 | Specify fractions direction, clockwise or counterclockwise. 48 | 49 | - wedgeprops : dict, optional, default: None 50 | 51 | Dict of arguments passed to the wedge objects making the pie. For example, you can pass in``wedgeprops = {‘linewidth’: 3}`` to set the width of the wedge border lines equal to 3. For more details, look at the doc/arguments of the wedge object. By default clip_on=False. 52 | 53 | - textprops : dict, optional, default: None 54 | 55 | Dict of arguments to pass to the text objects. 56 | 57 | - center : list of float, optional, default: (0, 0) 58 | 59 | Center position of the chart. Takes value (0, 0) or is a sequence of 2 scalars. 60 | 61 | - frame : bool, optional, default: False 62 | 63 | Plot axes frame with the chart if true. 64 | " 65 | Class { 66 | #name : #MLBPieCommand, 67 | #superclass : #MLBPyplotCommand, 68 | #instVars : [ 69 | 'x', 70 | 'explode', 71 | 'labels', 72 | 'colors', 73 | 'autopct', 74 | 'pctdistance', 75 | 'shadow', 76 | 'labeldistance', 77 | 'startangle', 78 | 'radius', 79 | 'counterclock', 80 | 'wedgeprops', 81 | 'textprops', 82 | 'center', 83 | 'frame' 84 | ], 85 | #category : #'MatplotLibBridge-Commands-Core' 86 | } 87 | 88 | { #category : #accessing } 89 | MLBPieCommand >> autopct [ 90 | 91 | ^ autopct 92 | ] 93 | 94 | { #category : #accessing } 95 | MLBPieCommand >> autopct: anObject [ 96 | autopct := anObject 97 | ] 98 | 99 | { #category : #accessing } 100 | MLBPieCommand >> center [ 101 | 102 | ^ center 103 | ] 104 | 105 | { #category : #accessing } 106 | MLBPieCommand >> center: anObject [ 107 | center := anObject 108 | ] 109 | 110 | { #category : #accessing } 111 | MLBPieCommand >> colors [ 112 | 113 | ^ colors 114 | ] 115 | 116 | { #category : #accessing } 117 | MLBPieCommand >> colors: anObject [ 118 | colors := anObject 119 | ] 120 | 121 | { #category : #accessing } 122 | MLBPieCommand >> counterclock [ 123 | 124 | ^ counterclock 125 | ] 126 | 127 | { #category : #accessing } 128 | MLBPieCommand >> counterclock: anObject [ 129 | counterclock := anObject 130 | ] 131 | 132 | { #category : #accessing } 133 | MLBPieCommand >> explode [ 134 | 135 | ^ explode 136 | ] 137 | 138 | { #category : #accessing } 139 | MLBPieCommand >> explode: anObject [ 140 | explode := anObject 141 | ] 142 | 143 | { #category : #accessing } 144 | MLBPieCommand >> frame [ 145 | 146 | ^ frame 147 | ] 148 | 149 | { #category : #accessing } 150 | MLBPieCommand >> frame: anObject [ 151 | frame := anObject 152 | ] 153 | 154 | { #category : #accessing } 155 | MLBPieCommand >> functionName [ 156 | ^ 'pie' 157 | ] 158 | 159 | { #category : #accessing } 160 | MLBPieCommand >> labeldistance [ 161 | 162 | ^ labeldistance 163 | ] 164 | 165 | { #category : #accessing } 166 | MLBPieCommand >> labeldistance: anObject [ 167 | labeldistance := anObject 168 | ] 169 | 170 | { #category : #accessing } 171 | MLBPieCommand >> labels [ 172 | 173 | ^ labels 174 | ] 175 | 176 | { #category : #accessing } 177 | MLBPieCommand >> labels: anObject [ 178 | labels := anObject 179 | ] 180 | 181 | { #category : #accessing } 182 | MLBPieCommand >> pctdistance [ 183 | 184 | ^ pctdistance 185 | ] 186 | 187 | { #category : #accessing } 188 | MLBPieCommand >> pctdistance: anObject [ 189 | pctdistance := anObject 190 | ] 191 | 192 | { #category : #accessing } 193 | MLBPieCommand >> radius [ 194 | 195 | ^ radius 196 | ] 197 | 198 | { #category : #accessing } 199 | MLBPieCommand >> radius: anObject [ 200 | radius := anObject 201 | ] 202 | 203 | { #category : #accessing } 204 | MLBPieCommand >> shadow [ 205 | 206 | ^ shadow 207 | ] 208 | 209 | { #category : #accessing } 210 | MLBPieCommand >> shadow: anObject [ 211 | shadow := anObject 212 | ] 213 | 214 | { #category : #accessing } 215 | MLBPieCommand >> startangle [ 216 | 217 | ^ startangle 218 | ] 219 | 220 | { #category : #accessing } 221 | MLBPieCommand >> startangle: anObject [ 222 | startangle := anObject 223 | ] 224 | 225 | { #category : #accessing } 226 | MLBPieCommand >> textprops [ 227 | 228 | ^ textprops 229 | ] 230 | 231 | { #category : #accessing } 232 | MLBPieCommand >> textprops: anObject [ 233 | textprops := anObject 234 | ] 235 | 236 | { #category : #accessing } 237 | MLBPieCommand >> wedgeprops [ 238 | 239 | ^ wedgeprops 240 | ] 241 | 242 | { #category : #accessing } 243 | MLBPieCommand >> wedgeprops: anObject [ 244 | wedgeprops := anObject 245 | ] 246 | 247 | { #category : #accessing } 248 | MLBPieCommand >> x [ 249 | 250 | ^ x 251 | ] 252 | 253 | { #category : #accessing } 254 | MLBPieCommand >> x: anObject [ 255 | x := anObject 256 | ] 257 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBBoxplotCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.boxplot function. 3 | 4 | I have the following attributes as described in matplotlib doc: 5 | -x : Array or a sequence of vectors. 6 | The input data. 7 | 8 | -notch : bool, optional (False) 9 | If True, will produce a notched box plot. Otherwise, a rectangular boxplot is produced. 10 | 11 | -sym : str, optional 12 | The default symbol for flier points. Enter an empty string (‘’) if you don’t want to show fliers. If None, then the fliers default to ‘b+’ If you want more control use the flierprops kwarg. 13 | 14 | -vert : bool, optional (True) 15 | If True (default), makes the boxes vertical. If False, everything is drawn horizontally. 16 | 17 | -whis : float, sequence, or string (default = 1.5) 18 | As a float, determines the reach of the whiskers past the first and third quartiles (e.g., Q3 + whis*IQR, IQR = interquartile range, Q3-Q1). Beyond the whiskers, data are considered outliers and are plotted as individual points. Set this to an unreasonably high value to force the whiskers to show the min and max values. Alternatively, set this to an ascending sequence of percentile (e.g., [5, 95]) to set the whiskers at specific percentiles of the data. Finally, whis can be the string 'range' to force the whiskers to the min and max of the data. 19 | 20 | -bootstrap : int, optional 21 | Specifies whether to bootstrap the confidence intervals around the median for notched boxplots. If bootstrap is None, no bootstrapping is performed, and notches are calculated using a Gaussian-based asymptotic approximation (see McGill, R., Tukey, J.W., and Larsen, W.A., 1978, and Kendall and Stuart, 1967). Otherwise, bootstrap specifies the number of times to bootstrap the median to determine its 95% confidence intervals. Values between 1000 and 10000 are recommended. 22 | 23 | -usermedians : array-like, optional 24 | An array or sequence whose first dimension (or length) is compatible with x. This overrides the medians computed by matplotlib for each element of usermedians that is not None. When an element of usermedians is None, the median will be computed by matplotlib as normal. 25 | 26 | -conf_intervals : array-like, optional 27 | Array or sequence whose first dimension (or length) is compatible with x and whose second dimension is 2. When the an element of conf_intervals is not None, the notch locations computed by matplotlib are overridden (provided notch is True). When an element of conf_intervals is None, the notches are computed by the method specified by the other kwargs (e.g., bootstrap). 28 | 29 | -positions : array-like, optional 30 | Sets the positions of the boxes. The ticks and limits are automatically set to match the positions. Defaults to range(1, N+1) where N is the number of boxes to be drawn. 31 | 32 | -widths : scalar or array-like 33 | Sets the width of each box either with a scalar or a sequence. The default is 0.5, or 0.15*(distance between extreme positions), if that is smaller. 34 | 35 | -patch_artist : bool, optional (False) 36 | If False produces boxes with the Line2D artist. Otherwise, boxes and drawn with Patch artists. 37 | 38 | -labels : sequence, optional 39 | Labels for each dataset. Length must be compatible with dimensions of x. 40 | 41 | -manage_xticks : bool, optional (True) 42 | If the function should adjust the xlim and xtick locations. 43 | 44 | -autorange : bool, optional (False) 45 | When True and the data are distributed such that the 25th and 75th percentiles are equal, whis is set to 'range' such that the whisker ends are at the minimum and maximum of the data. 46 | 47 | -meanline : bool, optional (False) 48 | If True (and showmeans is True), will try to render the mean as a line spanning the full width of the box according to meanprops (see below). Not recommended if shownotches is also True. Otherwise, means will be shown as points. 49 | " 50 | Class { 51 | #name : #MLBBoxplotCommand, 52 | #superclass : #MLBPyplotCommand, 53 | #instVars : [ 54 | 'x', 55 | 'notch', 56 | 'sym', 57 | 'vert', 58 | 'whis', 59 | 'bootstrap', 60 | 'usermedians', 61 | 'conf_intervals', 62 | 'positions', 63 | 'widths', 64 | 'patch_artist', 65 | 'labels', 66 | 'manage_xticks', 67 | 'autorange', 68 | 'meanline' 69 | ], 70 | #category : #'MatplotLibBridge-Commands-Core' 71 | } 72 | 73 | { #category : #accessing } 74 | MLBBoxplotCommand >> autorange [ 75 | 76 | ^ autorange 77 | ] 78 | 79 | { #category : #accessing } 80 | MLBBoxplotCommand >> autorange: anObject [ 81 | autorange := anObject 82 | ] 83 | 84 | { #category : #accessing } 85 | MLBBoxplotCommand >> bootstrap [ 86 | 87 | ^ bootstrap 88 | ] 89 | 90 | { #category : #accessing } 91 | MLBBoxplotCommand >> bootstrap: anObject [ 92 | bootstrap := anObject 93 | ] 94 | 95 | { #category : #accessing } 96 | MLBBoxplotCommand >> conf_intervals [ 97 | 98 | ^ conf_intervals 99 | ] 100 | 101 | { #category : #accessing } 102 | MLBBoxplotCommand >> conf_intervals: anObject [ 103 | conf_intervals := anObject 104 | ] 105 | 106 | { #category : #accessing } 107 | MLBBoxplotCommand >> functionName [ 108 | ^ 'boxplot' 109 | ] 110 | 111 | { #category : #accessing } 112 | MLBBoxplotCommand >> labels [ 113 | 114 | ^ labels 115 | ] 116 | 117 | { #category : #accessing } 118 | MLBBoxplotCommand >> labels: anObject [ 119 | labels := anObject 120 | ] 121 | 122 | { #category : #accessing } 123 | MLBBoxplotCommand >> manage_xticks [ 124 | 125 | ^ manage_xticks 126 | ] 127 | 128 | { #category : #accessing } 129 | MLBBoxplotCommand >> manage_xticks: anObject [ 130 | manage_xticks := anObject 131 | ] 132 | 133 | { #category : #accessing } 134 | MLBBoxplotCommand >> meanline [ 135 | 136 | ^ meanline 137 | ] 138 | 139 | { #category : #accessing } 140 | MLBBoxplotCommand >> meanline: anObject [ 141 | meanline := anObject 142 | ] 143 | 144 | { #category : #accessing } 145 | MLBBoxplotCommand >> notch [ 146 | 147 | ^ notch 148 | ] 149 | 150 | { #category : #accessing } 151 | MLBBoxplotCommand >> notch: anObject [ 152 | notch := anObject 153 | ] 154 | 155 | { #category : #accessing } 156 | MLBBoxplotCommand >> patch_artist [ 157 | 158 | ^ patch_artist 159 | ] 160 | 161 | { #category : #accessing } 162 | MLBBoxplotCommand >> patch_artist: anObject [ 163 | patch_artist := anObject 164 | ] 165 | 166 | { #category : #accessing } 167 | MLBBoxplotCommand >> positions [ 168 | 169 | ^ positions 170 | ] 171 | 172 | { #category : #accessing } 173 | MLBBoxplotCommand >> positions: anObject [ 174 | positions := anObject 175 | ] 176 | 177 | { #category : #accessing } 178 | MLBBoxplotCommand >> sym [ 179 | 180 | ^ sym 181 | ] 182 | 183 | { #category : #accessing } 184 | MLBBoxplotCommand >> sym: anObject [ 185 | sym := anObject 186 | ] 187 | 188 | { #category : #accessing } 189 | MLBBoxplotCommand >> usermedians [ 190 | 191 | ^ usermedians 192 | ] 193 | 194 | { #category : #accessing } 195 | MLBBoxplotCommand >> usermedians: anObject [ 196 | usermedians := anObject 197 | ] 198 | 199 | { #category : #accessing } 200 | MLBBoxplotCommand >> vert [ 201 | 202 | ^ vert 203 | ] 204 | 205 | { #category : #accessing } 206 | MLBBoxplotCommand >> vert: anObject [ 207 | vert := anObject 208 | ] 209 | 210 | { #category : #accessing } 211 | MLBBoxplotCommand >> whis [ 212 | 213 | ^ whis 214 | ] 215 | 216 | { #category : #accessing } 217 | MLBBoxplotCommand >> whis: anObject [ 218 | whis := anObject 219 | ] 220 | 221 | { #category : #accessing } 222 | MLBBoxplotCommand >> widths [ 223 | 224 | ^ widths 225 | ] 226 | 227 | { #category : #accessing } 228 | MLBBoxplotCommand >> widths: anObject [ 229 | widths := anObject 230 | ] 231 | 232 | { #category : #accessing } 233 | MLBBoxplotCommand >> x [ 234 | 235 | ^ x 236 | ] 237 | 238 | { #category : #accessing } 239 | MLBBoxplotCommand >> x: anObject [ 240 | x := anObject 241 | ] 242 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBPlotCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.plot function. 3 | 4 | From the documentation, I am configured with: 5 | - alpha: float (0.0 transparent through 1.0 opaque) 6 | - animated: [true | false] 7 | - antialiased: [true | false] 8 | - clip_on: [true | false] 9 | - color: any matplotlib color 10 | - dash_capstyle: [‘butt’ | ‘round’ | ‘projecting’] 11 | - dash_joinstyle: [‘miter’ | ‘round’ | ‘bevel’] 12 | - dashes: sequence of on/off ink in points 13 | - drawstyle: [‘default’ | ‘steps’ | ‘steps-pre’ | ‘steps-mid’ | ‘steps-post’] 14 | - fillstyle: [‘full’ | ‘left’ | ‘right’ | ‘bottom’ | ‘top’ | ‘none’] 15 | - gid : an id string 16 | - label: string or anything printable with ‘%s’ conversion. 17 | - linestyle: [‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | ''] 18 | - linewidth: float value in points 19 | - marker: A valid marker style 20 | - markeredgecolor: any matplotlib color 21 | - markeredgewidth: float value in points 22 | - markerfacecolor: any matplotlib color 23 | - markerfacecoloralt: any matplotlib color 24 | - markersize: float 25 | - markevery: [None | int | length-2 tuple of int | slice | list/array of int | float | length-2 tuple of float] 26 | - picker: float distance in points or callable pick 27 | - pickradius: float distance in points 28 | - rasterized: [true | false | nil] 29 | - solid_capstyle: [‘butt’ | ‘round’ | ‘projecting’] 30 | - solid_joinstyle: [‘miter’ | ‘round’ | ‘bevel’] 31 | - url: a url string 32 | - visible: [true | false] 33 | - zorder: any number 34 | " 35 | Class { 36 | #name : #MLBPlotCommand, 37 | #superclass : #MLBPyplotCommand, 38 | #instVars : [ 39 | 'x', 40 | 'y', 41 | 'alpha', 42 | 'animated', 43 | 'antialiased', 44 | 'clip_on', 45 | 'color', 46 | 'dash_capstyle', 47 | 'dash_joinstyle', 48 | 'dashes', 49 | 'drawstyle', 50 | 'fillstyle', 51 | 'gid', 52 | 'label', 53 | 'linestyle', 54 | 'linewidth', 55 | 'marker', 56 | 'markeredgecolor', 57 | 'markeredgewidth', 58 | 'markerfacecolor', 59 | 'markerfacecoloralt', 60 | 'markersize', 61 | 'markevery', 62 | 'picker', 63 | 'pickradius', 64 | 'rasterized', 65 | 'solid_capstyle', 66 | 'solid_joinstyle', 67 | 'url', 68 | 'visible', 69 | 'zorder' 70 | ], 71 | #category : #'MatplotLibBridge-Commands-Core' 72 | } 73 | 74 | { #category : #accessing } 75 | MLBPlotCommand >> alpha [ 76 | 77 | ^ alpha 78 | ] 79 | 80 | { #category : #accessing } 81 | MLBPlotCommand >> alpha: anObject [ 82 | alpha := anObject 83 | ] 84 | 85 | { #category : #accessing } 86 | MLBPlotCommand >> animated [ 87 | 88 | ^ animated 89 | ] 90 | 91 | { #category : #accessing } 92 | MLBPlotCommand >> animated: anObject [ 93 | animated := anObject 94 | ] 95 | 96 | { #category : #accessing } 97 | MLBPlotCommand >> antialiased [ 98 | 99 | ^ antialiased 100 | ] 101 | 102 | { #category : #accessing } 103 | MLBPlotCommand >> antialiased: anObject [ 104 | antialiased := anObject 105 | ] 106 | 107 | { #category : #accessing } 108 | MLBPlotCommand >> clip_on [ 109 | 110 | ^ clip_on 111 | ] 112 | 113 | { #category : #accessing } 114 | MLBPlotCommand >> clip_on: anObject [ 115 | clip_on := anObject 116 | ] 117 | 118 | { #category : #accessing } 119 | MLBPlotCommand >> color [ 120 | 121 | ^ color 122 | ] 123 | 124 | { #category : #accessing } 125 | MLBPlotCommand >> color: anObject [ 126 | color := anObject 127 | ] 128 | 129 | { #category : #accessing } 130 | MLBPlotCommand >> dash_capstyle [ 131 | 132 | ^ dash_capstyle 133 | ] 134 | 135 | { #category : #accessing } 136 | MLBPlotCommand >> dash_capstyle: anObject [ 137 | dash_capstyle := anObject 138 | ] 139 | 140 | { #category : #accessing } 141 | MLBPlotCommand >> dash_joinstyle [ 142 | 143 | ^ dash_joinstyle 144 | ] 145 | 146 | { #category : #accessing } 147 | MLBPlotCommand >> dash_joinstyle: anObject [ 148 | dash_joinstyle := anObject 149 | ] 150 | 151 | { #category : #accessing } 152 | MLBPlotCommand >> dashes [ 153 | 154 | ^ dashes 155 | ] 156 | 157 | { #category : #accessing } 158 | MLBPlotCommand >> dashes: anObject [ 159 | dashes := anObject 160 | ] 161 | 162 | { #category : #accessing } 163 | MLBPlotCommand >> drawstyle [ 164 | 165 | ^ drawstyle 166 | ] 167 | 168 | { #category : #accessing } 169 | MLBPlotCommand >> drawstyle: anObject [ 170 | drawstyle := anObject 171 | ] 172 | 173 | { #category : #accessing } 174 | MLBPlotCommand >> fillstyle [ 175 | 176 | ^ fillstyle 177 | ] 178 | 179 | { #category : #accessing } 180 | MLBPlotCommand >> fillstyle: anObject [ 181 | fillstyle := anObject 182 | ] 183 | 184 | { #category : #accessing } 185 | MLBPlotCommand >> functionName [ 186 | ^ 'plot' 187 | ] 188 | 189 | { #category : #accessing } 190 | MLBPlotCommand >> gid [ 191 | 192 | ^ gid 193 | ] 194 | 195 | { #category : #accessing } 196 | MLBPlotCommand >> gid: anObject [ 197 | gid := anObject 198 | ] 199 | 200 | { #category : #accessing } 201 | MLBPlotCommand >> label [ 202 | 203 | ^ label 204 | ] 205 | 206 | { #category : #accessing } 207 | MLBPlotCommand >> label: anObject [ 208 | label := anObject 209 | ] 210 | 211 | { #category : #accessing } 212 | MLBPlotCommand >> linestyle [ 213 | 214 | ^ linestyle 215 | ] 216 | 217 | { #category : #accessing } 218 | MLBPlotCommand >> linestyle: anObject [ 219 | linestyle := anObject 220 | ] 221 | 222 | { #category : #accessing } 223 | MLBPlotCommand >> linewidth [ 224 | 225 | ^ linewidth 226 | ] 227 | 228 | { #category : #accessing } 229 | MLBPlotCommand >> linewidth: anObject [ 230 | linewidth := anObject 231 | ] 232 | 233 | { #category : #accessing } 234 | MLBPlotCommand >> marker [ 235 | 236 | ^ marker 237 | ] 238 | 239 | { #category : #accessing } 240 | MLBPlotCommand >> marker: anObject [ 241 | marker := anObject 242 | ] 243 | 244 | { #category : #accessing } 245 | MLBPlotCommand >> markeredgecolor [ 246 | 247 | ^ markeredgecolor 248 | ] 249 | 250 | { #category : #accessing } 251 | MLBPlotCommand >> markeredgecolor: anObject [ 252 | markeredgecolor := anObject 253 | ] 254 | 255 | { #category : #accessing } 256 | MLBPlotCommand >> markeredgewidth [ 257 | 258 | ^ markeredgewidth 259 | ] 260 | 261 | { #category : #accessing } 262 | MLBPlotCommand >> markeredgewidth: anObject [ 263 | markeredgewidth := anObject 264 | ] 265 | 266 | { #category : #accessing } 267 | MLBPlotCommand >> markerfacecolor [ 268 | 269 | ^ markerfacecolor 270 | ] 271 | 272 | { #category : #accessing } 273 | MLBPlotCommand >> markerfacecolor: anObject [ 274 | markerfacecolor := anObject 275 | ] 276 | 277 | { #category : #accessing } 278 | MLBPlotCommand >> markerfacecoloralt [ 279 | 280 | ^ markerfacecoloralt 281 | ] 282 | 283 | { #category : #accessing } 284 | MLBPlotCommand >> markerfacecoloralt: anObject [ 285 | markerfacecoloralt := anObject 286 | ] 287 | 288 | { #category : #accessing } 289 | MLBPlotCommand >> markersize [ 290 | 291 | ^ markersize 292 | ] 293 | 294 | { #category : #accessing } 295 | MLBPlotCommand >> markersize: anObject [ 296 | markersize := anObject 297 | ] 298 | 299 | { #category : #accessing } 300 | MLBPlotCommand >> markevery [ 301 | 302 | ^ markevery 303 | ] 304 | 305 | { #category : #accessing } 306 | MLBPlotCommand >> markevery: anObject [ 307 | markevery := anObject 308 | ] 309 | 310 | { #category : #accessing } 311 | MLBPlotCommand >> picker [ 312 | 313 | ^ picker 314 | ] 315 | 316 | { #category : #accessing } 317 | MLBPlotCommand >> picker: anObject [ 318 | picker := anObject 319 | ] 320 | 321 | { #category : #accessing } 322 | MLBPlotCommand >> pickradius [ 323 | 324 | ^ pickradius 325 | ] 326 | 327 | { #category : #accessing } 328 | MLBPlotCommand >> pickradius: anObject [ 329 | pickradius := anObject 330 | ] 331 | 332 | { #category : #accessing } 333 | MLBPlotCommand >> rasterized [ 334 | 335 | ^ rasterized 336 | ] 337 | 338 | { #category : #accessing } 339 | MLBPlotCommand >> rasterized: anObject [ 340 | rasterized := anObject 341 | ] 342 | 343 | { #category : #accessing } 344 | MLBPlotCommand >> solid_capstyle [ 345 | 346 | ^ solid_capstyle 347 | ] 348 | 349 | { #category : #accessing } 350 | MLBPlotCommand >> solid_capstyle: anObject [ 351 | solid_capstyle := anObject 352 | ] 353 | 354 | { #category : #accessing } 355 | MLBPlotCommand >> solid_joinstyle [ 356 | 357 | ^ solid_joinstyle 358 | ] 359 | 360 | { #category : #accessing } 361 | MLBPlotCommand >> solid_joinstyle: anObject [ 362 | solid_joinstyle := anObject 363 | ] 364 | 365 | { #category : #accessing } 366 | MLBPlotCommand >> url [ 367 | 368 | ^ url 369 | ] 370 | 371 | { #category : #accessing } 372 | MLBPlotCommand >> url: anObject [ 373 | url := anObject 374 | ] 375 | 376 | { #category : #accessing } 377 | MLBPlotCommand >> visible [ 378 | 379 | ^ visible 380 | ] 381 | 382 | { #category : #accessing } 383 | MLBPlotCommand >> visible: anObject [ 384 | visible := anObject 385 | ] 386 | 387 | { #category : #accessing } 388 | MLBPlotCommand >> x [ 389 | 390 | ^ x 391 | ] 392 | 393 | { #category : #accessing } 394 | MLBPlotCommand >> x: anObject [ 395 | x := anObject 396 | ] 397 | 398 | { #category : #accessing } 399 | MLBPlotCommand >> y [ 400 | 401 | ^ y 402 | ] 403 | 404 | { #category : #accessing } 405 | MLBPlotCommand >> y: anObject [ 406 | y := anObject 407 | ] 408 | 409 | { #category : #accessing } 410 | MLBPlotCommand >> zorder [ 411 | 412 | ^ zorder 413 | ] 414 | 415 | { #category : #accessing } 416 | MLBPlotCommand >> zorder: anObject [ 417 | zorder := anObject 418 | ] 419 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBCommandListGenerator.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #MLBCommandListGenerator, 3 | #superclass : #MLBAbstractVisitor, 4 | #instVars : [ 5 | 'commandList' 6 | ], 7 | #category : #'MatplotLibBridge-Commands-Visitors' 8 | } 9 | 10 | { #category : #building } 11 | MLBCommandListGenerator >> afterBuildingPlot: aMLBAbstractPlot [ 12 | self commandList 13 | add: (MLBTitleCommand new 14 | s: aMLBAbstractPlot title; 15 | fontdict: aMLBAbstractPlot titleFontDict; 16 | loc: aMLBAbstractPlot titleLocation; 17 | yourself); 18 | add: (MLBAxis new 19 | v: aMLBAbstractPlot axis; 20 | yourself). 21 | aMLBAbstractPlot xAxis 22 | acceptVisitor: self. 23 | aMLBAbstractPlot hasXAxisTwin 24 | ifTrue: [ 25 | self commandList add: MLBTwinY new. 26 | aMLBAbstractPlot xAxisTwin acceptVisitor: self ]. 27 | aMLBAbstractPlot yAxis 28 | acceptVisitor: self. 29 | aMLBAbstractPlot hasYAxisTwin 30 | ifTrue: [ 31 | self commandList add: MLBTwinX new. 32 | aMLBAbstractPlot yAxisTwin acceptVisitor: self ]. 33 | aMLBAbstractPlot annotations do: [ :annotation | 34 | annotation acceptVisitor: self ]. 35 | aMLBAbstractPlot gridOnAxis ifNotNil: [ 36 | self commandList 37 | add: (MLBGridCommand new 38 | axis: aMLBAbstractPlot gridOnAxis; 39 | yourself) ] 40 | ] 41 | 42 | { #category : #building } 43 | MLBCommandListGenerator >> beforeBuildingPlot: aMLBAbstractPlot [ 44 | self commandList add: MLBClfCommand new. 45 | aMLBAbstractPlot style ifNotNil: [ :style | 46 | style acceptVisitor: self ] 47 | ] 48 | 49 | { #category : #helper } 50 | MLBCommandListGenerator >> buildPlot: plot withBeforeAfterHooks: aBlock [ 51 | self beforeBuildingPlot: plot. 52 | aBlock value: plot. 53 | self afterBuildingPlot: plot 54 | ] 55 | 56 | { #category : #accessing } 57 | MLBCommandListGenerator >> commandList [ 58 | ^ commandList 59 | ] 60 | 61 | { #category : #accessing } 62 | MLBCommandListGenerator >> commandList: anObject [ 63 | commandList := anObject 64 | ] 65 | 66 | { #category : #initialization } 67 | MLBCommandListGenerator >> initialize [ 68 | super initialize. 69 | self commandList: MLBCommandList new 70 | ] 71 | 72 | { #category : #visiting } 73 | MLBCommandListGenerator >> visitMLBAnnotation: aMLBAnnotation [ 74 | aMLBAnnotation position ifNil: [ 75 | MLBConfigurationUnfinished new 76 | object: self; 77 | selector: #position; 78 | signal ]. 79 | aMLBAnnotation verifyArrowProperties: aMLBAnnotation arrowProperties. 80 | self commandList 81 | add: (MLBAnnotateCommand new 82 | s: aMLBAnnotation content; 83 | xy: {aMLBAnnotation position x . aMLBAnnotation position y}; 84 | xytext: {aMLBAnnotation textPosition x . aMLBAnnotation textPosition y}; 85 | arrowprops: aMLBAnnotation arrowProperties; 86 | annotation_clip: aMLBAnnotation onlyVisibleInsideAxes; 87 | yourself) 88 | ] 89 | 90 | { #category : #visiting } 91 | MLBCommandListGenerator >> visitMLBAxis: aMLBAbstractAxis usingLabelCommandClass: labelCommandClass ticksCommandClass: ticksCommandClass scaleCommandClass: scaleCommandClass [ 92 | |tempTicks| 93 | self commandList 94 | add: (labelCommandClass new 95 | s: aMLBAbstractAxis title; 96 | yourself). 97 | tempTicks := ticksCommandClass new 98 | rotation: aMLBAbstractAxis labelsRotation; 99 | yourself. 100 | aMLBAbstractAxis labels ifNotNil: [ 101 | tempTicks 102 | ticks: (aMLBAbstractAxis ticks ifNil: [ (0 to: aMLBAbstractAxis labels size - 1) asArray ]); 103 | labels: aMLBAbstractAxis labels ]. 104 | self commandList 105 | add: tempTicks. 106 | aMLBAbstractAxis scale ifNotNil: [ 107 | self commandList 108 | add: (scaleCommandClass new 109 | scale: aMLBAbstractAxis scale; 110 | yourself) ] 111 | ] 112 | 113 | { #category : #visiting } 114 | MLBCommandListGenerator >> visitMLBBarPlot: aMLBBarPlot [ 115 | self buildPlot: aMLBBarPlot withBeforeAfterHooks: [ :plot | 116 | self commandList 117 | add: (MLBBarCommand new 118 | left: (0 to: plot data size - 1); 119 | height: plot data; 120 | tick_label: plot labels; 121 | color: plot color; 122 | yerr: plot errorBars; 123 | ecolor: plot errorBarsColor; 124 | "Next line is due to some kind of hack in matplotlib to align labels on right edge." 125 | width: (plot isAlignLabelRightEdge ifTrue: [ plot barWidth negated ] ifFalse: [ plot barWidth ]); 126 | align: plot align; 127 | log: plot logAxis; 128 | yourself) ] 129 | ] 130 | 131 | { #category : #visiting } 132 | MLBCommandListGenerator >> visitMLBBoxPlot: aMLBBoxPlot [ 133 | self buildPlot: aMLBBoxPlot withBeforeAfterHooks: [ :plot | 134 | plot isVertical 135 | ifTrue: [ 136 | plot configXAxis: [ :x | x ticks: (1 to: x labels size) ] ] 137 | ifFalse: [ 138 | plot configYAxis: [ :y | y ticks: (1 to: y labels size) ] ]. 139 | self commandList 140 | add: (MLBBoxplotCommand new 141 | x: plot dataList; 142 | labels: plot labels; 143 | vert: plot vertical; 144 | yourself) ] 145 | ] 146 | 147 | { #category : #visiting } 148 | MLBCommandListGenerator >> visitMLBCommandsGenerator: aMLBCommandsGenerator [ 149 | aMLBCommandsGenerator generateCommandsIn: self commandList 150 | ] 151 | 152 | { #category : #visiting } 153 | MLBCommandListGenerator >> visitMLBLegend: aMLBLegend [ 154 | self commandList 155 | add: (MLBLegendCommand new 156 | fontsize: aMLBLegend fontSize; 157 | framealpha: aMLBLegend frameTransparency; 158 | fancybox: aMLBLegend hasFancyBox; 159 | shadow: aMLBLegend hasShadow; 160 | loc: aMLBLegend location; 161 | ncol: aMLBLegend numberOfColumns; 162 | title: aMLBLegend title; 163 | yourself) 164 | ] 165 | 166 | { #category : #visiting } 167 | MLBCommandListGenerator >> visitMLBLine: aMLBLine [ 168 | self commandList 169 | add: 170 | (MLBPlotCommand new 171 | x: aMLBLine x; 172 | y: aMLBLine y; 173 | linestyle: aMLBLine style; 174 | marker: aMLBLine marker; 175 | alpha: aMLBLine alpha; 176 | color: aMLBLine colorHexString; 177 | label: aMLBLine label; 178 | linewidth: aMLBLine width; 179 | yourself) 180 | ] 181 | 182 | { #category : #visiting } 183 | MLBCommandListGenerator >> visitMLBLinePlot: aMLBLinePlot [ 184 | self buildPlot: aMLBLinePlot withBeforeAfterHooks: [ :plot | 185 | plot lines do: [ :line | 186 | line acceptVisitor: self ]. 187 | 188 | (plot lines anySatisfy: #hasLabel) 189 | ifTrue: [ 190 | self commandList 191 | add: MLBLegendCommand new ]. 192 | 193 | (plot legend isNotNil and: [ (plot lines anySatisfy: #hasLabel) ]) 194 | ifTrue: [ plot legend acceptVisitor: self ] ] 195 | ] 196 | 197 | { #category : #visiting } 198 | MLBCommandListGenerator >> visitMLBPiePlot: aMLBPiePlot [ 199 | self buildPlot: aMLBPiePlot withBeforeAfterHooks: [ :plot | 200 | self commandList 201 | add: (MLBPieCommand new 202 | x: plot data; 203 | labels: plot labels; 204 | shadow: plot hasShadow; 205 | explode: plot explode; 206 | startangle: plot startAngle; 207 | radius: plot radius; 208 | counterclock: plot isCounterClock; 209 | colors: plot colors; 210 | yourself) ] 211 | ] 212 | 213 | { #category : #visiting } 214 | MLBCommandListGenerator >> visitMLBPointsLine: aMLBPointsLine [ 215 | self visitMLBLine: aMLBPointsLine 216 | ] 217 | 218 | { #category : #visiting } 219 | MLBCommandListGenerator >> visitMLBScatterPlot2: aMLBScatterPlots [ 220 | self buildPlot: aMLBScatterPlots withBeforeAfterHooks: [ :plot | 221 | ((plot data groupedBy: #marker) associations 222 | sorted: [ :a :b | 223 | (plot markersOrder indexOf: a key) < (plot markersOrder indexOf: b key) ]) 224 | do: [ :assoc | 225 | |marker scatterData| 226 | marker := assoc key. 227 | scatterData := assoc value. 228 | self commandList 229 | add: 230 | (MLBScatterCommand new 231 | x: (scatterData collect: #x); 232 | y: (scatterData collect: #y); 233 | s: (scatterData collect: #size); 234 | c: (scatterData collect: #color); 235 | marker: marker; 236 | yourself) ] ] 237 | ] 238 | 239 | { #category : #visiting } 240 | MLBCommandListGenerator >> visitMLBScatterPlot: aMLBScatterPlot [ 241 | self buildPlot: aMLBScatterPlot withBeforeAfterHooks: [ :plot | 242 | self commandList 243 | add: 244 | (MLBScatterCommand new 245 | x: plot x; 246 | y: plot y; 247 | s: plot pointSizes; 248 | c: 249 | (plot colors isCollection 250 | ifTrue: [ plot colors collect: [ :c | '#' , c asHexString ] ] 251 | ifFalse: [ '#' , plot colors asHexString ]); 252 | yourself) ] 253 | ] 254 | 255 | { #category : #visiting } 256 | MLBCommandListGenerator >> visitMLBStackedBarPlot: aMLBStackedBarPlot [ 257 | self buildPlot: aMLBStackedBarPlot withBeforeAfterHooks: [ :plot | 258 | self commandList 259 | add: 260 | (MLBBarCommand new 261 | left: (0 to: plot dataList size - 1); 262 | height: (plot dataList collect: #first); 263 | tick_label: plot labels; 264 | color: plot colorList first; 265 | yerr: 266 | (plot errorBarsList 267 | ifNotNil: [ :list | list collect: #first ]); 268 | ecolor: 269 | (plot errorBarsColorList 270 | ifNotNil: [ :list | list asOrderedCollection first ]); 271 | "Next line is due to some kind of hack in matplotlib to align labels on right edge." 272 | width: (plot isAlignLabelRightEdge ifTrue: [ plot barWidth negated ] ifFalse: [ plot barWidth ]); 273 | align: plot align; 274 | log: plot logAxis; 275 | yourself). 276 | 2 to: plot dataList anyOne size do: [ :i | 277 | self commandList 278 | add: 279 | (MLBBarCommand new 280 | left: (0 to: plot dataList size - 1); 281 | height: (plot dataList collect: [ :d | d at: i ]); 282 | bottom: 283 | (plot dataList 284 | collect: [ :d | ((1 to: i - 1) collect: [ :j | d at: j ]) sum ]); 285 | color: (plot colorList at: i); 286 | yerr: 287 | (plot errorBarsList 288 | ifNotNil: [ :list | list collect: [ :e | e at: i ] ]); 289 | ecolor: 290 | (plot errorBarsColorList 291 | ifNotNil: [ :list | (list asOrderedCollection at: i) asHexString ]); 292 | "Next line is due to some kind of hack in matplotlib to align labels on right edge." 293 | width: (plot isAlignLabelRightEdge ifTrue: [ plot barWidth negated ] ifFalse: [ plot barWidth ]); 294 | align: plot align; 295 | yourself) ] ] 296 | ] 297 | 298 | { #category : #visiting } 299 | MLBCommandListGenerator >> visitMLBStyleSheet: aMLBStyleSheet [ 300 | aMLBStyleSheet properties do: [ :p | 301 | p acceptVisitor: self ] 302 | ] 303 | 304 | { #category : #visiting } 305 | MLBCommandListGenerator >> visitMLBStyleSheetProperty: aMLBStyleSheetProperty [ 306 | self commandList 307 | add: (MLBRcCommand new 308 | group: aMLBStyleSheetProperty groupName; 309 | setProperty: aMLBStyleSheetProperty name to: aMLBStyleSheetProperty value; 310 | yourself) 311 | ] 312 | 313 | { #category : #visiting } 314 | MLBCommandListGenerator >> visitMLBXAxis: aMLBXAxis [ 315 | self visitMLBAxis: aMLBXAxis usingLabelCommandClass: MLBXLabelCommand ticksCommandClass: MLBXTicksCommand scaleCommandClass: MLBXScaleCommand. 316 | self commandList 317 | add: (MLBXLimCommand new 318 | xmin: aMLBXAxis min; 319 | xmax: aMLBXAxis max; 320 | yourself) 321 | ] 322 | 323 | { #category : #visiting } 324 | MLBCommandListGenerator >> visitMLBXBlockLine: aMLBXBlockLine [ 325 | self visitMLBLine: aMLBXBlockLine 326 | ] 327 | 328 | { #category : #visiting } 329 | MLBCommandListGenerator >> visitMLBXKCDStyleSheet: aMLBXKCDStyleSheet [ 330 | self commandList add: MLBXkcdCommand new 331 | ] 332 | 333 | { #category : #visiting } 334 | MLBCommandListGenerator >> visitMLBYAxis: aMLBYAxis [ 335 | self visitMLBAxis: aMLBYAxis usingLabelCommandClass: MLBYLabelCommand ticksCommandClass: MLBYTicksCommand scaleCommandClass: MLBYScaleCommand. 336 | self commandList 337 | add: (MLBYLimCommand new 338 | ymin: aMLBYAxis min; 339 | ymax: aMLBYAxis max; 340 | yourself) 341 | ] 342 | 343 | { #category : #visiting } 344 | MLBCommandListGenerator >> visitMLBYBlockLine: aMLBYBlockLine [ 345 | self visitMLBLine: aMLBYBlockLine 346 | ] 347 | -------------------------------------------------------------------------------- /src/MatplotLibBridge-Commands/MLBLegendCommand.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am a wrapper for the matplotlib.pyplot.legend function. 3 | 4 | From the doc, I can be configured with: 5 | - loc : int or string or pair of floats, default: ‘upper right’ 6 | 7 | The location of the legend. Possible codes are: 8 | 9 | Location String Location Code 10 | ‘best’ 0 11 | ‘upper right’ 1 12 | ‘upper left’ 2 13 | ‘lower left’ 3 14 | ‘lower right’ 4 15 | ‘right’ 5 16 | ‘center left’ 6 17 | ‘center right’ 7 18 | ‘lower center’ 8 19 | ‘upper center’ 9 20 | ‘center’ 10 21 | Alternatively can be a 2-tuple giving x, y of the lower-left corner of the legend in axes coordinates (in which case bbox_to_anchor will be ignored). 22 | 23 | - bbox_to_anchor : matplotlib.transforms.BboxBase instance or tuple of floats 24 | 25 | Specify any arbitrary location for the legend in bbox_transform coordinates (default Axes coordinates). 26 | 27 | For example, to put the legend’s upper right hand corner in the center of the axes the following keywords can be used: 28 | 29 | loc='upper right', bbox_to_anchor=(0.5, 0.5) 30 | ncol : integer 31 | 32 | The number of columns that the legend has. Default is 1. 33 | 34 | - prop : None or matplotlib.font_manager.FontProperties or dict 35 | 36 | The font properties of the legend. If None (default), the current matplotlib.rcParams will be used. 37 | 38 | - fontsize : int or float or {‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’} 39 | 40 | Controls the font size of the legend. If the value is numeric the size will be the absolute font size in points. String values are relative to the current default font size. This argument is only used if prop is not specified. 41 | 42 | - numpoints : None or int 43 | 44 | The number of marker points in the legend when creating a legend entry for a line/matplotlib.lines.Line2D. Default is None which will take the value from the legend.numpoints rcParam. 45 | 46 | - scatterpoints : None or int 47 | 48 | The number of marker points in the legend when creating a legend entry for a scatter plot/ matplotlib.collections.PathCollection. Default is None which will take the value from the legend.scatterpoints rcParam. 49 | 50 | - scatteryoffsets : iterable of floats 51 | 52 | The vertical offset (relative to the font size) for the markers created for a scatter plot legend entry. 0.0 is at the base the legend text, and 1.0 is at the top. To draw all markers at the same height, set to [0.5]. Default [0.375, 0.5, 0.3125]. 53 | 54 | - markerscale : None or int or float 55 | 56 | The relative size of legend markers compared with the originally drawn ones. Default is None which will take the value from the legend.markerscale rcParam. 57 | 58 | - markerfirst : bool 59 | 60 | if True, legend marker is placed to the left of the legend label if False, legend marker is placed to the right of the legend label 61 | 62 | - frameon : None or bool 63 | 64 | Control whether the legend should be drawn on a patch (frame). Default is None which will take the value from the legend.frameon rcParam. 65 | 66 | - fancybox : None or bool 67 | 68 | Control whether round edges should be enabled around the FancyBboxPatch which makes up the legend’s background. Default is None which will take the value from the legend.fancybox rcParam. 69 | 70 | - shadow : None or bool 71 | 72 | Control whether to draw a shadow behind the legend. Default is None which will take the value from the legend.shadow rcParam. 73 | 74 | - framealpha : None or float 75 | 76 | Control the alpha transparency of the legend’s background. Default is None which will take the value from the legend.framealpha rcParam. 77 | 78 | - facecolor : None or “inherit” or a color spec 79 | 80 | Control the legend’s background color. Default is None which will take the value from the legend.facecolor rcParam. If ""inherit"", it will take the axes.facecolor rcParam. 81 | 82 | - edgecolor : None or “inherit” or a color spec 83 | 84 | Control the legend’s background patch edge color. Default is None which will take the value from the legend.edgecolor rcParam. If ""inherit"", it will take the axes.edgecolor rcParam. 85 | 86 | - mode : {“expand”, None} 87 | 88 | If mode is set to ""expand"" the legend will be horizontally expanded to fill the axes area (or bbox_to_anchor if defines the legend’s size). 89 | 90 | - bbox_transform : None or matplotlib.transforms.Transform 91 | 92 | The transform for the bounding box (bbox_to_anchor). For a value of None (default) the Axes’ transAxes transform will be used. 93 | 94 | - title : str or None 95 | 96 | The legend’s title. Default is no title (None). 97 | 98 | - borderpad : float or None 99 | 100 | The fractional whitespace inside the legend border. Measured in font-size units. Default is None which will take the value from the legend.borderpad rcParam. 101 | 102 | - labelspacing : float or None 103 | 104 | The vertical space between the legend entries. Measured in font-size units. Default is None which will take the value from the legend.labelspacing rcParam. 105 | 106 | - handlelength : float or None 107 | 108 | The length of the legend handles. Measured in font-size units. Default is None which will take the value from the legend.handlelength rcParam. 109 | 110 | - handletextpad : float or None 111 | 112 | The pad between the legend handle and text. Measured in font-size units. Default is None which will take the value from the legend.handletextpad rcParam. 113 | 114 | - borderaxespad : float or None 115 | 116 | The pad between the axes and legend border. Measured in font-size units. Default is None which will take the value from the legend.borderaxespad rcParam. 117 | 118 | - columnspacing : float or None 119 | 120 | The spacing between columns. Measured in font-size units. Default is None which will take the value from the legend.columnspacing rcParam. 121 | 122 | - handler_map : dict or None 123 | 124 | The custom dictionary mapping instances or types to a legend handler. This handler_map updates the default handler map found at matplotlib.legend.Legend.get_legend_handler_map(). 125 | " 126 | Class { 127 | #name : #MLBLegendCommand, 128 | #superclass : #MLBPyplotCommand, 129 | #instVars : [ 130 | 'loc', 131 | 'bbox_to_anchor', 132 | 'ncol', 133 | 'prop', 134 | 'fontsize', 135 | 'numpoints', 136 | 'scatterpoints', 137 | 'scatteryoffsets', 138 | 'markerscale', 139 | 'markerfirst', 140 | 'frameon', 141 | 'fancybox', 142 | 'shadow', 143 | 'framealpha', 144 | 'facecolor', 145 | 'edgecolor', 146 | 'mode', 147 | 'bbox_transform', 148 | 'title', 149 | 'borderpad', 150 | 'labelspacing', 151 | 'handlelength', 152 | 'handletextpad', 153 | 'borderaxespad', 154 | 'columnspacing', 155 | 'handler_map' 156 | ], 157 | #category : #'MatplotLibBridge-Commands-Core' 158 | } 159 | 160 | { #category : #accessing } 161 | MLBLegendCommand >> bbox_to_anchor [ 162 | 163 | ^ bbox_to_anchor 164 | ] 165 | 166 | { #category : #accessing } 167 | MLBLegendCommand >> bbox_to_anchor: anObject [ 168 | bbox_to_anchor := anObject 169 | ] 170 | 171 | { #category : #accessing } 172 | MLBLegendCommand >> bbox_transform [ 173 | 174 | ^ bbox_transform 175 | ] 176 | 177 | { #category : #accessing } 178 | MLBLegendCommand >> bbox_transform: anObject [ 179 | bbox_transform := anObject 180 | ] 181 | 182 | { #category : #accessing } 183 | MLBLegendCommand >> borderaxespad [ 184 | 185 | ^ borderaxespad 186 | ] 187 | 188 | { #category : #accessing } 189 | MLBLegendCommand >> borderaxespad: anObject [ 190 | borderaxespad := anObject 191 | ] 192 | 193 | { #category : #accessing } 194 | MLBLegendCommand >> borderpad [ 195 | 196 | ^ borderpad 197 | ] 198 | 199 | { #category : #accessing } 200 | MLBLegendCommand >> borderpad: anObject [ 201 | borderpad := anObject 202 | ] 203 | 204 | { #category : #accessing } 205 | MLBLegendCommand >> columnspacing [ 206 | 207 | ^ columnspacing 208 | ] 209 | 210 | { #category : #accessing } 211 | MLBLegendCommand >> columnspacing: anObject [ 212 | columnspacing := anObject 213 | ] 214 | 215 | { #category : #accessing } 216 | MLBLegendCommand >> edgecolor [ 217 | 218 | ^ edgecolor 219 | ] 220 | 221 | { #category : #accessing } 222 | MLBLegendCommand >> edgecolor: anObject [ 223 | edgecolor := anObject 224 | ] 225 | 226 | { #category : #accessing } 227 | MLBLegendCommand >> facecolor [ 228 | 229 | ^ facecolor 230 | ] 231 | 232 | { #category : #accessing } 233 | MLBLegendCommand >> facecolor: anObject [ 234 | facecolor := anObject 235 | ] 236 | 237 | { #category : #accessing } 238 | MLBLegendCommand >> fancybox [ 239 | 240 | ^ fancybox 241 | ] 242 | 243 | { #category : #accessing } 244 | MLBLegendCommand >> fancybox: anObject [ 245 | fancybox := anObject 246 | ] 247 | 248 | { #category : #accessing } 249 | MLBLegendCommand >> fontsize [ 250 | 251 | ^ fontsize 252 | ] 253 | 254 | { #category : #accessing } 255 | MLBLegendCommand >> fontsize: anObject [ 256 | fontsize := anObject 257 | ] 258 | 259 | { #category : #accessing } 260 | MLBLegendCommand >> framealpha [ 261 | 262 | ^ framealpha 263 | ] 264 | 265 | { #category : #accessing } 266 | MLBLegendCommand >> framealpha: anObject [ 267 | framealpha := anObject 268 | ] 269 | 270 | { #category : #accessing } 271 | MLBLegendCommand >> frameon [ 272 | 273 | ^ frameon 274 | ] 275 | 276 | { #category : #accessing } 277 | MLBLegendCommand >> frameon: anObject [ 278 | frameon := anObject 279 | ] 280 | 281 | { #category : #accessing } 282 | MLBLegendCommand >> functionName [ 283 | ^ 'legend' 284 | ] 285 | 286 | { #category : #accessing } 287 | MLBLegendCommand >> handlelength [ 288 | 289 | ^ handlelength 290 | ] 291 | 292 | { #category : #accessing } 293 | MLBLegendCommand >> handlelength: anObject [ 294 | handlelength := anObject 295 | ] 296 | 297 | { #category : #accessing } 298 | MLBLegendCommand >> handler_map [ 299 | 300 | ^ handler_map 301 | ] 302 | 303 | { #category : #accessing } 304 | MLBLegendCommand >> handler_map: anObject [ 305 | handler_map := anObject 306 | ] 307 | 308 | { #category : #accessing } 309 | MLBLegendCommand >> handletextpad [ 310 | 311 | ^ handletextpad 312 | ] 313 | 314 | { #category : #accessing } 315 | MLBLegendCommand >> handletextpad: anObject [ 316 | handletextpad := anObject 317 | ] 318 | 319 | { #category : #accessing } 320 | MLBLegendCommand >> labelspacing [ 321 | 322 | ^ labelspacing 323 | ] 324 | 325 | { #category : #accessing } 326 | MLBLegendCommand >> labelspacing: anObject [ 327 | labelspacing := anObject 328 | ] 329 | 330 | { #category : #accessing } 331 | MLBLegendCommand >> loc [ 332 | 333 | ^ loc 334 | ] 335 | 336 | { #category : #accessing } 337 | MLBLegendCommand >> loc: anObject [ 338 | loc := anObject 339 | ] 340 | 341 | { #category : #accessing } 342 | MLBLegendCommand >> markerfirst [ 343 | 344 | ^ markerfirst 345 | ] 346 | 347 | { #category : #accessing } 348 | MLBLegendCommand >> markerfirst: anObject [ 349 | markerfirst := anObject 350 | ] 351 | 352 | { #category : #accessing } 353 | MLBLegendCommand >> markerscale [ 354 | 355 | ^ markerscale 356 | ] 357 | 358 | { #category : #accessing } 359 | MLBLegendCommand >> markerscale: anObject [ 360 | markerscale := anObject 361 | ] 362 | 363 | { #category : #accessing } 364 | MLBLegendCommand >> mode [ 365 | 366 | ^ mode 367 | ] 368 | 369 | { #category : #accessing } 370 | MLBLegendCommand >> mode: anObject [ 371 | mode := anObject 372 | ] 373 | 374 | { #category : #accessing } 375 | MLBLegendCommand >> ncol [ 376 | 377 | ^ ncol 378 | ] 379 | 380 | { #category : #accessing } 381 | MLBLegendCommand >> ncol: anObject [ 382 | ncol := anObject 383 | ] 384 | 385 | { #category : #accessing } 386 | MLBLegendCommand >> numpoints [ 387 | 388 | ^ numpoints 389 | ] 390 | 391 | { #category : #accessing } 392 | MLBLegendCommand >> numpoints: anObject [ 393 | numpoints := anObject 394 | ] 395 | 396 | { #category : #accessing } 397 | MLBLegendCommand >> prop [ 398 | 399 | ^ prop 400 | ] 401 | 402 | { #category : #accessing } 403 | MLBLegendCommand >> prop: anObject [ 404 | prop := anObject 405 | ] 406 | 407 | { #category : #accessing } 408 | MLBLegendCommand >> scatterpoints [ 409 | 410 | ^ scatterpoints 411 | ] 412 | 413 | { #category : #accessing } 414 | MLBLegendCommand >> scatterpoints: anObject [ 415 | scatterpoints := anObject 416 | ] 417 | 418 | { #category : #accessing } 419 | MLBLegendCommand >> scatteryoffsets [ 420 | 421 | ^ scatteryoffsets 422 | ] 423 | 424 | { #category : #accessing } 425 | MLBLegendCommand >> scatteryoffsets: anObject [ 426 | scatteryoffsets := anObject 427 | ] 428 | 429 | { #category : #accessing } 430 | MLBLegendCommand >> shadow [ 431 | 432 | ^ shadow 433 | ] 434 | 435 | { #category : #accessing } 436 | MLBLegendCommand >> shadow: anObject [ 437 | shadow := anObject 438 | ] 439 | 440 | { #category : #accessing } 441 | MLBLegendCommand >> title [ 442 | 443 | ^ title 444 | ] 445 | 446 | { #category : #accessing } 447 | MLBLegendCommand >> title: anObject [ 448 | title := anObject 449 | ] 450 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MatplotLibBridge 2 | A bridge to provide the ability to Pharo user to use Python's Matplotlib. 3 | 4 | ## Install 5 | This project has been tested on Linux and Mac OS. If someone manage to use it on Windows, please let me know. 6 | ### Python side 7 | Obviously, you need to have Python 3 installed on your machine. Furthermore, you need matplotlib package installed as well. The following link explains how to do it [install matplotlib](https://matplotlib.org/faq/installing_faq.html). 8 | 9 | ### Pharo side 10 | To install this project in your image, open a playground and execute the following code snippet: 11 | ``` 12 | Metacello new 13 | baseline: 'MatplotLibBridge'; 14 | repository: 'github://juliendelplanque/MatplotLibBridge/src'; 15 | load 16 | ``` 17 | 18 | This will install version 0.1 of the project. You should only depend on released versions for your projects. The master branch of this repository contains latest commits and might not be stable. 19 | 20 | Once MatplotLibBridge is installed in your image, you need to configure [Python3Generator](https://github.com/juliendelplanque/Python3Generator) to use the Python interpreter you prefer. My advise is to use the FFI interpreter using: `P3GInterpreter useFFIInterpreter`. If your `python3` binary is located in a standard path in your file system, it should be fine, else you can manually set the path to `python3` binary using for example: `P3GInterpreter current pathToPython: '/usr/bin/python3'`. 21 | 22 | ## How to use MatplotLibBridge? 23 | This page provides some examples to illustrate how to use MatplotLibBridge. For each example, the method `#show` is called when the plot is built. This method open an interactive window showing a preview of the plot. If you want to export the plot in a file, you can use `#generateIn:` which takes a `FileReference` as argument. This method creates an image file with a format corresponding to the extension of the file reference. The available formats are `.png`, `.svg` and `.pdf`. For example: `plot generateIn: '/tmp/foo.png'` will generate the `plot` in the file `/tmp/foo.png` in png format. 24 | 25 | ### Creating a line plot 26 | The following code snippet creates a line plot for the factorial function between 0 and 10. It also illustrates that it is possible to use LaTeX code as marker for the points. Using `#label:` message allows to give name to the line that will be displayed in a corner of the plot. 27 | ``` 28 | MLBLinePlot new 29 | addPointsLine: [ :line | 30 | line 31 | points: ((0 to: 10) collect: [ :i | i @ i factorial ]); 32 | marker: '$\triangledown$'; 33 | label: 'Factorial' ]; 34 | show 35 | ``` 36 | 37 | ![exampleLineplot](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/exampleLineplot.png) 38 | 39 | ### Creating a line plot using Y-Block line 40 | The following code snippet creates a line plot for the factorial function between 0 and 10 using MLBYBlockLine. It is totally equivalent to the preceding example (in the result) but this is another way to express the plot using MatplotLibBridge. 41 | ``` 42 | MLBLinePlot new 43 | addYBlockLine: [ :line | 44 | line 45 | x: (0 to: 10); 46 | yBlock: #factorial; 47 | marker: '$\triangledown$'; 48 | label: 'Factorial' ]; 49 | show 50 | ``` 51 | 52 | ![exampleLineplotYBlockLine](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/exampleLineplotYBlockLine.png) 53 | 54 | ### Creating multi-lines plot 55 | The following code snippet creates a multi-lines plot for the square root function, the third-root function and the fourth-root function between 0 and 1000. It also shows how to change the color of a line (using `#color:`) and how to change its style (using `#style:`). Available styles for a line can be accessed using `MLBLine>>#lineStyles` 56 | ``` 57 | MLBLinePlot new 58 | addPointsLine: [ :line | line points: ((0 to: 1000) collect: [ :i | i @ i sqrt ]) ]; 59 | addPointsLine: [ :line | 60 | line 61 | points: ((0 to: 1000) collect: [ :i | i @ (i nthRoot: 3) ]); 62 | color: Color red; 63 | style: '--' ]; 64 | addPointsLine: [ :line | 65 | line 66 | points: ((0 to: 1000) collect: [ :i | i @ (i nthRoot: 4) ]); 67 | color: Color blue; 68 | style: 'dotted' ]; 69 | show 70 | ``` 71 | 72 | ![exampleMultilineplot](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/exampleMultilineplot.png) 73 | 74 | ### Changing line width in line plot or multi-lines plot 75 | It is possible to configure the width of each line in a line plot using `#width:`. 76 | ``` 77 | MLBLinePlot new 78 | addPointsLine: [ :line | 79 | line 80 | points: ((0 to: 10) collect: [ :i | i @ i ]); 81 | width: 5; 82 | color: Color blue ]; 83 | addPointsLine: [ :line | 84 | line 85 | points: ((0 to: 10) collect: [ :i | i @ (i * 2) ]); 86 | width: 3; 87 | color: Color red ]; 88 | addPointsLine: [ :line | 89 | "#width = 1 if not specified." 90 | line 91 | points: ((0 to: 10) collect: [ :i | i @ (i * 3) ]); 92 | color: Color green ]; 93 | show 94 | ``` 95 | 96 | ![exampleChangingLineWidthOfLineplot](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/exampleChangingLineWidthOfLineplot.png) 97 | 98 | ### Discontinuous lines in line plot or multi-lines plot 99 | If you create points having `Float nan` as x or y, it allows to create discontinuous lines. 100 | ``` 101 | MLBLinePlot new 102 | addPointsLine: [ :line | 103 | line 104 | points: 105 | ((-10 to: -0) collect: [ :i | i @ 1 negated ]) , {(0 @ Float nan)} 106 | , ((0 to: 10) collect: [ :i | i @ 1 ]); 107 | label: 'Discontinous line'; 108 | color: Color red ]; 109 | addPointsLine: [ :line | 110 | line 111 | points: 112 | ((-10 to: -0) collect: [ :i | i @ 0.5 negated ]) 113 | , ((0 to: 10) collect: [ :i | i @ 0.5 ]); 114 | label: 'Continous line'; 115 | color: Color blue ]; 116 | show 117 | ``` 118 | 119 | ![exampleDiscontinuousLineplot](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/exampleDiscontinuousLineplot.png) 120 | 121 | ### Set an axis to be in logarithmic scale 122 | Calling the method `#logScale` in #configYAxis block makes the scale of the concerned axis logarithmic. Other scales are available, see `MLBAbstractAxis>>validScales`. 123 | ``` 124 | MLBLinePlot new 125 | addPointsLine: [ :line | 126 | line 127 | points: ((0 to: 100) collect: [ :i | i @ i exp ]); 128 | label: 'exp(x)' ]; 129 | configYAxis: [ :yAxis | 130 | yAxis logScale ]; 131 | show 132 | ``` 133 | 134 | ![exampleLogscaleLineplot](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/exampleLogscaleLineplot.png) 135 | 136 | ### Creating a bar plot 137 | The following code snippet creates a bar plot for some data and to display their standard deviation. This example also illustrates how to do some basic configuration of x and y axes (`#configXAxis:` and `#configYAxis:`). 138 | ``` 139 | |data std | 140 | data := #(20 35 30 35 27). 141 | std := #(2 3 4 1 2). 142 | 143 | MLBBarPlot new 144 | data: data; 145 | labels: #('G1' 'G2' 'G3' 'G4' 'G5'); 146 | color: Color blue; 147 | configXAxis: [ :xAxis | 148 | xAxis 149 | labelsRotation: 45 ]; 150 | configYAxis: [ :yAxis | 151 | yAxis 152 | title: 'Y label' ]; 153 | title: 'Barplot example'; 154 | errorBars: std; 155 | errorBarsColor: Color black; 156 | alignLabelCenter; 157 | show. 158 | ``` 159 | 160 | ![exampleBarplot](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/exampleBarplot.png) 161 | 162 | ### Creating an horizontal box plot 163 | The following code snippet creates an horizontal box plot for some random data. 164 | ``` 165 | MLBBoxPlot new 166 | dataList: {((1 to: 100) collect: [ :i | (1 to: 10) atRandom ]) . ((1 to: 100) collect: [ :i | (1 to: 10) atRandom ])}; 167 | beHorizontal; 168 | configYAxis: [ :axis| 169 | axis 170 | labels: #('Data 1' 'Data 2') ]; 171 | show 172 | ``` 173 | 174 | ![exampleHorizontalBoxplot](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/exampleHorizontalBoxplot.png) 175 | 176 | ### Creating a stacked bar plot 177 | The following code snippet creates a stacked bar plot for some data and to display their standard deviation. The `#dataList` of a `MLBStackedBarPlot` should be a collection of collections of the same arity. It also shows how to rotate the labels of an axis. 178 | ``` 179 | | menMeans womenMeans menStd womenStd data std | 180 | menMeans := #(20 35 30 35 27). 181 | womenMeans := #(25 32 34 20 25). 182 | menStd := #(2 3 4 1 2). 183 | womenStd := #(3 5 2 3 3). 184 | 185 | data := (1 to: menMeans size) collect: [ :i | 186 | { menMeans at: i. womenMeans at: i } ]. 187 | std := (1 to: menStd size) collect: [ :i | 188 | { menStd at: i. womenStd at: i } ]. 189 | 190 | MLBStackedBarPlot new 191 | dataList: data; 192 | colorList: {Color blue. Color pink}; 193 | title: 'Scores by group and gender'; 194 | configXAxis: [ :xAxis | 195 | xAxis 196 | labelsRotation: 45; 197 | labels: #('G1' 'G2' 'G3' 'G4' 'G5') ]; 198 | configYAxis: [ :yAxis | 199 | yAxis 200 | title: 'Scores' ]; 201 | errorBarsList: std; 202 | errorBarsColorList: { Color black . Color black }; 203 | alignLabelCenter; 204 | show. 205 | ``` 206 | 207 | ![exampleStackedBarplot](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/exampleStackedBarplot.png) 208 | 209 | ### Creating a vertical box plot 210 | The following code snippet creates a vertical box plot for some random data. No need to call `#beVertical` since this is the default orientation of the plot. 211 | ``` 212 | MLBBoxPlot new 213 | dataList: {((1 to: 100) collect: [ :i | (1 to: 10) atRandom ])}; 214 | configXAxis: [ :xAxis| 215 | xAxis 216 | labels: #('Data') ]; 217 | show 218 | ``` 219 | 220 | ![exampleVerticalBoxplot](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/exampleVerticalBoxplot.png) 221 | 222 | ### Creating a pie plot 223 | The following code snippet creates a pie box plot for some data that sum to 100. You can optionally add `labels:`, set the a shadow or not (`hasShadow:`), configure the `axis:` (here we want to have a round pie, so we set it to `'equal'`), explode each part of the pie at different degrees (here only the part concerning `30` data is exploded) and choose the start angle. 224 | ``` 225 | MLBPiePlot new 226 | data: #(50 20 30); 227 | labels: #(One Two Three); 228 | hasShadow: false; 229 | axis: 'equal'; 230 | explode: #(0 0 0.1); 231 | startAngle: -90; 232 | show 233 | ``` 234 | 235 | ![examplePieplot](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/examplePieplot.png) 236 | 237 | ### Creating a scatter plot (new API) 238 | The following code snippet creates a scatter plot for some random data. The principle is to create MLBScatterData, to set them a position, a color, a size and a shape 239 | ``` 240 | MLBScatterPlot2 new 241 | data: ((1 to: 20) collect: [ :i | 242 | (MLBScatterData position: (1 to: 15) atRandom @ (1 to: 15) atRandom size: (20 to: 500) atRandom) 243 | color: Color random; 244 | marker: MLBConstants markers atRandom; 245 | yourself ]); 246 | show 247 | ``` 248 | 249 | ![exampleScatterplot2](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/exampleScatterplot2.png) 250 | 251 | ### Creating a scatter plot (old API) 252 | The following code snippet creates a scatter plot for some random data. Here we create `MLBCircle`s with a random position, a random diameter and a random color and provide them to the `MLBScatterPlot` instance. 253 | ``` 254 | MLBScatterPlot new 255 | circles: ((1 to: 10) collect: [ :i | 256 | (MLBCircle position: (1 to: 15) atRandom @ (1 to: 15) atRandom size: (20 to: 500) atRandom) 257 | color: Color random; 258 | yourself ]); 259 | show 260 | ``` 261 | 262 | ![exampleScatterplot](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/exampleScatterplot.png) 263 | 264 | ### Using LaTeX in legend 265 | The following code snippet shows you how to create a line plot with LaTeX code for lines' labels. In fact, with MatplotLibBridge, you can use LaTeX in any String you provide. 266 | ``` 267 | | interval | 268 | interval := 1 to: 1000. 269 | MLBLinePlot new 270 | addPointsLine: [ :line | 271 | line 272 | points: (interval collect: [ :i | i @ i sqrt ]); 273 | color: Color green; 274 | label: '$\sqrt[2]{x}$' ]; 275 | addPointsLine: [ :line | 276 | line 277 | points: (interval collect: [ :i | i @ (i nthRoot: 3) ]); 278 | color: Color red; 279 | label: '$\sqrt[3]{x}$' ]; 280 | addPointsLine: [ :line | 281 | line 282 | points: (interval collect: [ :i | i @ (i nthRoot: 4) ]); 283 | color: Color blue; 284 | label: '$\sqrt[4]{x}$' ]; 285 | addPointsLine: [ :line | 286 | line 287 | points: (interval collect: [ :i | i @ i log ]); 288 | label: '$log(x)$' ]; 289 | configXAxis: [ :axis | axis min: 0 ]; 290 | configYAxis: [ :axis | axis min: 0 ]; 291 | addLegend; 292 | show 293 | ``` 294 | 295 | ![exampleLegend](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/exampleLegend.png) 296 | 297 | ### Annotations 298 | On any plot, you can add annotations. An annotation is an extra graphical element you add on your plot such as for example an arrow pointing to a certain interesting location on the plot. 299 | ``` 300 | MLBLinePlot new 301 | addPointsLine: [ :line | 302 | line 303 | points: ((1 to: 50 by: 2) collect: [ :i | i @ (i ** 3) ]); 304 | style: 'solid'; 305 | marker: 'None'; 306 | color: 307 | (Color 308 | r: 0 309 | g: 0 310 | b: 0 311 | alpha: 0.3) ]; 312 | addAnnotation: [ :annotation | 313 | annotation 314 | content: 'a thing'; 315 | position: 10 @ (10 ** 3); 316 | textPosition: 10 @ (10 ** 4); 317 | arrowProperties: {('arrowstyle' -> '<|-')} asDictionary ]; 318 | addAnnotation: [ :annotation | 319 | annotation 320 | content: 'another thing'; 321 | position: 30 @ (30 ** 3); 322 | textPosition: 35 @ (30 ** 3 + 10); 323 | arrowProperties: 324 | {('facecolor' -> 'black'). 325 | ('shrink' -> 4)} asDictionary ]; 326 | show 327 | ``` 328 | 329 | ![exampleAnnotations](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/exampleAnnotations.png) 330 | 331 | ### Style sheet 332 | MatplotLib allows to use stylesheet to reuse/change easily plot styles. The bridge actually expose this API with the `MLBStyleSheet` object. The name of properties are the same as in the python version. For more information see the official documentation of matplotlib: https://matplotlib.org/users/customizing.html. 333 | ``` 334 | | style | 335 | style := MLBStyleSheet new 336 | setProperty: 'color' ofGroup: 'text' to: 'red'; 337 | setProperty: 'weight' ofGroup: 'font' to: 'bold'; 338 | yourself. 339 | 340 | MLBBarPlot new 341 | data: #(1 2 3); 342 | labels: #('Group 1' 'Group 2' 'Group 3'); 343 | title: 'A title'; 344 | style: style; 345 | show 346 | ``` 347 | 348 | ![exampleStyleSheet](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/exampleStyleSheet.png) 349 | 350 | -------------------------------------------------------------------------------- /src/MatplotLibBridge/MLBExamples.class.st: -------------------------------------------------------------------------------- 1 | " 2 | I am holding examples of use of this framework in my class side messages, 3 | " 4 | Class { 5 | #name : #MLBExamples, 6 | #superclass : #Object, 7 | #category : #'MatplotLibBridge-Examples' 8 | } 9 | 10 | { #category : #samples } 11 | MLBExamples class >> annotationsSample [ 12 | 13 | ^ MLBLinePlot new 14 | addPointsLine: [ :line | 15 | line 16 | points: ((1 to: 50 by: 2) collect: [ :i | i @ (i ** 3) ]); 17 | style: 'solid'; 18 | marker: 'None'; 19 | color: 20 | (Color black alpha: 0.3) ]; 21 | addAnnotation: [ :annotation | 22 | annotation 23 | content: 'a thing'; 24 | position: 10 @ (10 ** 3); 25 | textPosition: 10 @ (10 ** 4); 26 | arrowProperties: {('arrowstyle' -> '<|-')} asDictionary ]; 27 | addAnnotation: [ :annotation | 28 | annotation 29 | content: 'another thing'; 30 | position: 30 @ (30 ** 3); 31 | textPosition: 35 @ (30 ** 3 + 10); 32 | arrowProperties: 33 | {('facecolor' -> 'black'). 34 | ('shrink' -> 4)} asDictionary ]; 35 | yourself 36 | ] 37 | 38 | { #category : #samples } 39 | MLBExamples class >> barplotSample [ 40 | 41 | |data std | 42 | data := #(20 35 30 35 27). 43 | std := #(2 3 4 1 2). 44 | 45 | ^ MLBBarPlot new 46 | data: data; 47 | labels: #('G1' 'G2' 'G3' 'G4' 'G5'); 48 | color: Color blue; 49 | configXAxis: [ :xAxis | 50 | xAxis 51 | labelsRotation: 45 ]; 52 | configYAxis: [ :yAxis | 53 | yAxis 54 | title: 'Y label' ]; 55 | title: 'Barplot example'; 56 | errorBars: std; 57 | errorBarsColor: Color black; 58 | alignLabelCenter; 59 | yourself. 60 | ] 61 | 62 | { #category : #samples } 63 | MLBExamples class >> changingLineWidthOfLineplotSample [ 64 | 65 | ^ MLBLinePlot new 66 | addPointsLine: [ :line | 67 | line 68 | points: ((0 to: 10) collect: [ :i | i @ i ]); 69 | width: 5; 70 | color: Color blue ]; 71 | addPointsLine: [ :line | 72 | line 73 | points: ((0 to: 10) collect: [ :i | i @ (i * 2) ]); 74 | width: 3; 75 | color: Color red ]; 76 | addPointsLine: [ :line | 77 | "#width = 1 if not specified." 78 | line 79 | points: ((0 to: 10) collect: [ :i | i @ (i * 3) ]); 80 | color: Color green ]; 81 | yourself 82 | ] 83 | 84 | { #category : #samples } 85 | MLBExamples class >> discontinuousLineplotSample [ 86 | 87 | ^ MLBLinePlot new 88 | addPointsLine: [ :line | 89 | line 90 | points: 91 | ((-10 to: -0) collect: [ :i | i @ 1 negated ]) , {(0 @ Float nan)} 92 | , ((0 to: 10) collect: [ :i | i @ 1 ]); 93 | label: 'Discontinous line'; 94 | color: Color red ]; 95 | addPointsLine: [ :line | 96 | line 97 | points: 98 | ((-10 to: -0) collect: [ :i | i @ 0.5 negated ]) 99 | , ((0 to: 10) collect: [ :i | i @ 0.5 ]); 100 | label: 'Continous line'; 101 | color: Color blue ]; 102 | yourself 103 | ] 104 | 105 | { #category : #examples } 106 | MLBExamples class >> exampleAnnotations [ 107 | self annotationsSample show 108 | ] 109 | 110 | { #category : #examples } 111 | MLBExamples class >> exampleBarplot [ 112 | self barplotSample show. 113 | ] 114 | 115 | { #category : #examples } 116 | MLBExamples class >> exampleChangingLineWidthOfLineplot [ 117 | self changingLineWidthOfLineplotSample show 118 | ] 119 | 120 | { #category : #examples } 121 | MLBExamples class >> exampleDiscontinuousLineplot [ 122 | self discontinuousLineplotSample show 123 | ] 124 | 125 | { #category : #examples } 126 | MLBExamples class >> exampleHorizontalBoxplot [ 127 | self horizontalBoxplotSample show 128 | ] 129 | 130 | { #category : #examples } 131 | MLBExamples class >> exampleLegend [ 132 | self legendSample show 133 | ] 134 | 135 | { #category : #examples } 136 | MLBExamples class >> exampleLineplot [ 137 | self lineplotSample show 138 | ] 139 | 140 | { #category : #examples } 141 | MLBExamples class >> exampleLineplotYBlockLine [ 142 | self lineplotYBlockLineSample show 143 | ] 144 | 145 | { #category : #examples } 146 | MLBExamples class >> exampleLogscaleLineplot [ 147 | self logscaleLineplotSample show 148 | ] 149 | 150 | { #category : #examples } 151 | MLBExamples class >> exampleMultilineplot [ 152 | self multilineplotSample show 153 | ] 154 | 155 | { #category : #examples } 156 | MLBExamples class >> examplePieplot [ 157 | self pieplotSample show 158 | ] 159 | 160 | { #category : #examples } 161 | MLBExamples class >> exampleScatterplot [ 162 | self scatterplotSample show 163 | ] 164 | 165 | { #category : #examples } 166 | MLBExamples class >> exampleScatterplot2 [ 167 | self scatterplot2Sample show 168 | ] 169 | 170 | { #category : #examples } 171 | MLBExamples class >> exampleStackedBarplot [ 172 | self stackedBarplotSample show 173 | ] 174 | 175 | { #category : #examples } 176 | MLBExamples class >> exampleStyleSheet [ 177 | self styleSheetSample show 178 | ] 179 | 180 | { #category : #examples } 181 | MLBExamples class >> exampleVerticalBoxplot [ 182 | self verticalBoxplotSample show 183 | ] 184 | 185 | { #category : #'accessing - documentation' } 186 | MLBExamples class >> examples [ 187 | ^ self methodsWithExamplePragma collect: [ :selector | 188 | selector value: self ] 189 | ] 190 | 191 | { #category : #'accessing - documentation' } 192 | MLBExamples class >> generateMarkdown [ 193 | ^ String streamContents: [ :stream | 194 | self generateMarkdownOn: stream ] 195 | ] 196 | 197 | { #category : #'accessing - documentation' } 198 | MLBExamples class >> generateMarkdownOn: aStream [ 199 | aStream 200 | << '## How to use MatplotLibBridge?'; 201 | << Character lf; 202 | << 'This page provides some examples to illustrate how to use MatplotLibBridge. For each example, the method `#show` is called when the plot is built. This method open an interactive window showing a preview of the plot. If you want to export the plot in a file, you can use `#generateIn:` which takes a `FileReference` as argument. This method creates an image file with a format corresponding to the extension of the file reference. The available formats are `.png`, `.svg` and `.pdf`. For example: `plot generateIn: ''/tmp/foo.png''` will generate the `plot` in the file `/tmp/foo.png` in png format.'; 203 | << Character lf; 204 | << Character lf. 205 | self methodsWithExamplePragma 206 | do: [ :selector | 207 | | method pragma | 208 | method := self class >> selector. 209 | pragma := method pragmaAt: self pragmaForExample. 210 | aStream 211 | << '### '; 212 | << (pragma argumentAt: 2); 213 | << Character lf; 214 | << (pragma argumentAt: 3); 215 | << Character lf. 216 | self printCodeForExampleMethod: method on: aStream. 217 | aStream 218 | << Character lf; 219 | << '!['; 220 | << selector; 221 | << '](https://raw.githubusercontent.com/juliendelplanque/MatplotLibBridge/master/plots/'; 222 | << selector; 223 | << '.png)'; 224 | << Character lf; 225 | << Character lf ] 226 | ] 227 | 228 | { #category : #'example plots generation' } 229 | MLBExamples class >> generatePlotsForExamplesIn: aDirectoryFileReference [ 230 | self assert: aDirectoryFileReference isDirectory. 231 | 232 | self methodsWithExamplePragma do: [ :selector | 233 | (selector value: self) generateIn: aDirectoryFileReference / (selector , '.png') ] 234 | ] 235 | 236 | { #category : #samples } 237 | MLBExamples class >> horizontalBoxplotSample [ 238 | 239 | ^ MLBBoxPlot new 240 | dataList: {((1 to: 100) collect: [ :i | (1 to: 10) atRandom ]) . ((1 to: 100) collect: [ :i | (1 to: 10) atRandom ])}; 241 | beHorizontal; 242 | configYAxis: [ :axis| 243 | axis 244 | labels: #('Data 1' 'Data 2') ]; 245 | yourself 246 | ] 247 | 248 | { #category : #samples } 249 | MLBExamples class >> legendSample [ 250 | 251 | | interval | 252 | interval := 1 to: 1000. 253 | ^ MLBLinePlot new 254 | addPointsLine: [ :line | 255 | line 256 | points: (interval collect: [ :i | i @ i sqrt ]); 257 | color: Color green; 258 | label: '$\sqrt[2]{x}$' ]; 259 | addPointsLine: [ :line | 260 | line 261 | points: (interval collect: [ :i | i @ (i nthRoot: 3) ]); 262 | color: Color red; 263 | label: '$\sqrt[3]{x}$' ]; 264 | addPointsLine: [ :line | 265 | line 266 | points: (interval collect: [ :i | i @ (i nthRoot: 4) ]); 267 | color: Color blue; 268 | label: '$\sqrt[4]{x}$' ]; 269 | addPointsLine: [ :line | 270 | line 271 | points: (interval collect: [ :i | i @ i log ]); 272 | label: '$log(x)$' ]; 273 | configXAxis: [ :axis | axis min: 0 ]; 274 | configYAxis: [ :axis | axis min: 0 ]; 275 | addLegend; 276 | yourself 277 | ] 278 | 279 | { #category : #samples } 280 | MLBExamples class >> lineplotSample [ 281 | 282 | ^ MLBLinePlot new 283 | addPointsLine: [ :line | 284 | line 285 | points: ((0 to: 10) collect: [ :i | i @ i factorial ]); 286 | marker: '$\triangledown$'; 287 | label: 'Factorial' ]; 288 | yourself 289 | ] 290 | 291 | { #category : #samples } 292 | MLBExamples class >> lineplotYBlockLineSample [ 293 | 294 | ^ MLBLinePlot new 295 | addYBlockLine: [ :line | 296 | line 297 | x: (0 to: 10); 298 | yBlock: #factorial; 299 | marker: '$\triangledown$'; 300 | label: 'Factorial' ]; 301 | yourself 302 | ] 303 | 304 | { #category : #samples } 305 | MLBExamples class >> logscaleLineplotSample [ 306 | >validScales`.'> 307 | ^ MLBLinePlot new 308 | addPointsLine: [ :line | 309 | line 310 | points: ((0 to: 100) collect: [ :i | i @ i exp ]); 311 | label: 'exp(x)' ]; 312 | configYAxis: [ :yAxis | 313 | yAxis logScale ]; 314 | yourself 315 | ] 316 | 317 | { #category : #'accessing - documentation' } 318 | MLBExamples class >> methodsWithExamplePragma [ 319 | ^ ((Pragma allNamed: self pragmaForExample in: self class) sorted: [ :a :b | (a argumentAt: 1) < (b argumentAt: 1) ] ) collect: #methodSelector 320 | ] 321 | 322 | { #category : #samples } 323 | MLBExamples class >> multilineplotSample [ 324 | >#lineStyles`'> 325 | ^ MLBLinePlot new 326 | addPointsLine: [ :line | line points: ((0 to: 1000) collect: [ :i | i @ i sqrt ]) ]; 327 | addPointsLine: [ :line | 328 | line 329 | points: ((0 to: 1000) collect: [ :i | i @ (i nthRoot: 3) ]); 330 | color: Color red; 331 | style: '--' ]; 332 | addPointsLine: [ :line | 333 | line 334 | points: ((0 to: 1000) collect: [ :i | i @ (i nthRoot: 4) ]); 335 | color: Color blue; 336 | style: 'dotted' ]; 337 | yourself 338 | ] 339 | 340 | { #category : #samples } 341 | MLBExamples class >> pieplotSample [ 342 | 343 | ^ MLBPiePlot new 344 | data: #(50 20 30); 345 | labels: #(One Two Three); 346 | hasShadow: false; 347 | axis: 'equal'; 348 | explode: #(0 0 0.1); 349 | startAngle: -90; 350 | yourself 351 | ] 352 | 353 | { #category : #'accessing - documentation' } 354 | MLBExamples class >> pragmaForExample [ 355 | ^ #mlbExampleNumber:named:description: 356 | ] 357 | 358 | { #category : #private } 359 | MLBExamples class >> printCodeForExampleMethod: aCompiledMethod on: aStream [ 360 | "Print the code concerning the example from #aCompiledMethod method on #aStream." 361 | 362 | | lines | 363 | lines := aCompiledMethod sourceCode lines. 364 | 365 | aStream 366 | << '```'; 367 | << Character lf. 368 | lines allButFirst allButFirst do: [ :line | 369 | aStream 370 | << line allButFirst; "Remove first tab character." 371 | << Character lf ]. 372 | aStream 373 | << '```'; 374 | << Character lf. 375 | ] 376 | 377 | { #category : #samples } 378 | MLBExamples class >> scatterplot2Sample [ 379 | 380 | ^ MLBScatterPlot2 new 381 | data: ((1 to: 20) collect: [ :i | 382 | (MLBScatterData position: (1 to: 15) atRandom @ (1 to: 15) atRandom size: (20 to: 500) atRandom) 383 | color: Color random; 384 | marker: MLBMarkerStyle random; 385 | yourself ]); 386 | yourself 387 | ] 388 | 389 | { #category : #samples } 390 | MLBExamples class >> scatterplotSample [ 391 | 392 | ^ MLBScatterPlot new 393 | circles: ((1 to: 10) collect: [ :i | 394 | (MLBCircle position: (1 to: 15) atRandom @ (1 to: 15) atRandom size: (20 to: 500) atRandom) 395 | color: Color random; 396 | yourself ]); 397 | yourself 398 | ] 399 | 400 | { #category : #samples } 401 | MLBExamples class >> stackedBarplotSample [ 402 | 403 | | menMeans womenMeans menStd womenStd data std | 404 | menMeans := #(20 35 30 35 27). 405 | womenMeans := #(25 32 34 20 25). 406 | menStd := #(2 3 4 1 2). 407 | womenStd := #(3 5 2 3 3). 408 | 409 | data := (1 to: menMeans size) collect: [ :i | 410 | { menMeans at: i. womenMeans at: i } ]. 411 | std := (1 to: menStd size) collect: [ :i | 412 | { menStd at: i. womenStd at: i } ]. 413 | 414 | ^ MLBStackedBarPlot new 415 | dataList: data; 416 | colorList: {Color blue. Color pink}; 417 | title: 'Scores by group and gender'; 418 | configXAxis: [ :xAxis | 419 | xAxis 420 | labelsRotation: 45; 421 | labels: #('G1' 'G2' 'G3' 'G4' 'G5') ]; 422 | configYAxis: [ :yAxis | 423 | yAxis 424 | title: 'Scores' ]; 425 | errorBarsList: std; 426 | errorBarsColorList: { Color black . Color black }; 427 | alignLabelCenter; 428 | yourself. 429 | ] 430 | 431 | { #category : #samples } 432 | MLBExamples class >> styleSheetSample [ 433 | 434 | | style | 435 | style := MLBStyleSheet new 436 | setProperty: 'color' ofGroup: 'text' to: 'red'; 437 | setProperty: 'weight' ofGroup: 'font' to: 'bold'; 438 | yourself. 439 | 440 | ^ MLBBarPlot new 441 | data: #(1 2 3); 442 | labels: #('Group 1' 'Group 2' 'Group 3'); 443 | title: 'A title'; 444 | style: style; 445 | yourself 446 | ] 447 | 448 | { #category : #samples } 449 | MLBExamples class >> verticalBoxplotSample [ 450 | 451 | ^ MLBBoxPlot new 452 | dataList: {((1 to: 100) collect: [ :i | (1 to: 10) atRandom ])}; 453 | configXAxis: [ :xAxis| 454 | xAxis 455 | labels: #('Data') ]; 456 | yourself 457 | ] 458 | --------------------------------------------------------------------------------