Plot.drawShapes in macro failing ...and I can't figure out why

Hi all,

I’m trying to plot some data using the drawShapes plot option. IJ 1.52i (fiji) on mac mojave.

I checked out the “verticalBoxesAndWhiskers” in the examples. …copied into a new macro window and ran it there. …no problem! …I get a nice set of boxes drawn.

However when I tried using Plot.drawShapes in a macro (IJ1 macro) file of my own it failed, saying:

‘,’ expected in line 764
Plot.drawShapes(“boxes width=30”, , yy1,yy2,yy3 …

wot!!!:hushed: …it’s saying it’s expecting a 2nd “,” instead of the 2nd argument??

I tried it first with some of my own arrays and got the same error. So I thought it was me getting it wrong, so I copied the exact same code from the “Examples” into my file and got exactly the same error!

So if I run the example code inside an IJ macro window it will work correctly, but if I copy the exact same code into file, then try to run that file with runMacro, it will fail, saying the it expects a “,” instead of the 2nd argument.

…any clues what’s up?

I tried saving the example code to a file, then executing it from the file via runMacro() and it also works correctly in that case.

So it is something to do with the specifics of my other macro file causing it to fail, however I can’t figure it out from the error message. I don’t have problems with any other Plot calls in the same macro file (I’m making at least 10-15 other plots in the same file while it runs).

I just realised that the formatting posting removed my characters with < and > so it looks like I forgot an “x” argument array.

The error indication dialog box indicates the first xxCenters array is being flagged as expecting a ‘,’ instead of an argument (see attached)

This looks possibly like a bug somewhere in IJ.

I’m using the vanilla code from the Examples. If I place that code at the start of my script it works. However if I move it into the script slightly it stops working with the error above. I’ve looked at the code that seems to cause it to fail, and can’t see anything that would indicate a problem.

Below is the code where the inserted Example code fails with the above error (drawShapes throws the error above).
If I move the code snippet above the “if (production) {…” block then it will be fine - display the plot without any problems.

// --- setup ------------------------------------------------------------------------

// get dicom files to test

if ( production ) {                                     // production use get file names etc from args
        args = split(getArgument(), " ");
        testID = args[0];
        scriptDir = args[1]; 
        files = Array.slice(args,2);

        print("got args:");
        for (i=0; i<args.length; i++) {
                print(i,"   ", args[i]);
        print("files: ");
        for (i=0; i<files.length; i++) {
                print(i,"   ", files[i]);

} else {
        // -- for testing - popup up dialog asking which directory to search for files
        dir = "/Users/dave/Desktop/CT/GE/dicom-study1/";
        if ( lengthOf(dir) == 0 ) {
                dir = getDirectory("Choose a directory with test files");

        print("dir:", dir);

        fileList = getFileList(dir);
        files = newArray();
        for (i=0; i<fileList.length; i++) {
                if ( matches(fileList[i], ".*\.dcm$") ) files = Array.concat( files, dir+fileList[i] );

        testID = 1;
        scriptDir = "/Users/dave/src/cloud/testing-scripts/";

// drawShapes demo example code snippet:

Plot.create("Vertical Boxes and Whiskers_", "X", "Y");
   Plot.setFrameSize(600, 350);
   Plot.setLimits(-1, 20, 0, 7);
   xxCenter = Array.getSequence(4);
   xxCenter = newArray( 5,7, 11, 15 );
   yy1 = newArray(3,4,3,3);//First Quartiles
   yy2 = newArray(2,3,2.5,1.5);
   yy3 = newArray(3,4,3,3);//Medians
   yy4 = newArray(4,4.5,5.5,3.5);
   yy5 = newArray(3,4,3,3);
   Plot.setColor("blue", "#ccccff");
   Plot.drawShapes("boxes width=30", xxCenter, yy1, yy2, yy3, yy4, yy5);

I am unable to reproduce this problem. I saved the macro at Help>Examples>Plots>Shapes as a file (“Plot_Shapes_.ijm”), run it using Plugins>Macros>Run and it worked as expected, creating six plots. I am using ImageJ 1.52m21 on macOS 10.12.6.