/* Simple macro to plot 2 columns from the active table. Inspired even simpler macro by Kees Straatman https://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF/software-1/imagej-macros#Plot%20results 1st version 082319 v211022 Updated color choices f1-3: updated functions f4-6 updated colors. F7: getColorArrayFromColorName_v230908. v231013: Table headers only split by tabs. F1: Replaced function: pad. F2: Updated getColorFromColorName function (012324). v240402: Added axis title option. */ macro Quick_plot_2_Table_Columns { requires("1.52a"); macroL = "QuickPlot_2_TableColumns_v240402.ijm"; saveSettings(); /* To restore settings at the end */ run("Plots...", "width=512 height=384 font=14 draw draw_ticks"); headings = split(Table.headings, "\t"); sortChoices = newArray("no","ascending","descending"); types = newArray( "dot","line","connected circle","filled","bar","separated bar","circle","box","triangle","diamond","cross", "x"); colorChoicesStd = newArray("red", "green", "blue", "cyan", "magenta", "yellow", "pink", "orange", "violet"); colorChoicesMod = newArray("garnet", "gold", "aqua_modern", "blue_accent_modern", "blue_dark_modern", "blue_modern", "blue_honolulu", "gray_modern", "green_dark_modern", "green_modern", "green_modern_accent", "green_spring_accent", "orange_modern", "pink_modern", "purple_modern", "red_n_modern", "red_modern", "tan_modern", "violet_modern", "yellow_modern"); colorChoicesNeon = newArray("jazzberry_jam", "radical_red", "wild_watermelon", "outrageous_orange", "supernova_orange", "atomic_tangerine", "neon_carrot", "sunglow", "laser_lemon", "electric_lime", "screamin'_green", "magic_mint", "blizzard_blue", "dodger_blue", "shocking_pink", "razzle_dazzle_rose", "hot_magenta"); colorChoices = Array.concat("black", colorChoices, colorChoicesStd, colorChoicesMod, colorChoicesNeon); Dialog.create("Choose Y and X Columns"); Dialog.addMessage("Macro: " + macroL); Dialog.addMessage("Additional data and formatting can be added from the built-in plot menu"); Dialog.addChoice("Select the results for the X axis", headings, headings[0]); Dialog.addChoice("Select the results for the Y axis", headings, headings[1]); Dialog.addString("X-axis title \(if different from selected columnn name\)", "", 20); Dialog.addString("Y-axis title \(if different from selected columnn name\)", "", 20); Dialog.addString("Plot title \(if different from auto-generated\)", "", 20); Dialog.addCheckbox("Sort XY pairs by ascending X values?",true); Dialog.addChoice("Select plot type", types, types[2]); Dialog.addChoice("Select the plot color", colorChoices, "black"); Dialog.addChoice("Select the color filling symbols or connecting line", colorChoices, "black"); Dialog.addNumber("Choose line width",2,0,2,"pixels"); // Dialog.addCheckbox("Log X scale?",false); // Dialog.addCheckbox("Log Y scale?",false); Dialog.show(); xChoice = Dialog.getChoice; yChoice = Dialog.getChoice; xTitle = Dialog.getString(); if (xTitle=="") xTitle = xChoice; yTitle = Dialog.getString(); if (yTitle=="") yTitle = yChoice; plotTitle = Dialog.getString; if (plotTitle=="") plotTitle = xTitle + "-" + yTitle; xSort = Dialog.getCheckbox; type = Dialog.getChoice; plotColor = Dialog.getChoice; plotColor2 = Dialog.getChoice; lineWidth = Dialog.getNumber; // logX = Dialog.getCheckbox; // logY = Dialog.getCheckbox; xValues = Table.getColumn(xChoice); yValues = Table.getColumn(yChoice); if (xSort){ rankXs = Array.rankPositions(xValues); xValues = Array.sort(xValues); yValuesSorted = newArray(yValues.length); for (i=0; i