Tuesday, August 12, 2014

Excel Figures with Directional Arrows

I needed streamlines and a I wanted arrows to show the flow direction of the flow.

I scoured the web and didn't find a single solution but I did find the pieces I needed to make an VBA macro to add directional arrows to my streamlines

Here's the instructions

Pull in your Original XY Data in the Original Sheet - I use the Matlab code below to generate constant streamlines

In the Control sheet, enter the number of points before an arrowhead is drawn in the appropriate cell
This sets the distance between arrowheads

Click Parse Data
This will take the original data and break it up into many different columns that can be added as individual series

Click on the figure in the Figure sheet
This is a prerequisite for the next step

From the XL toolbox addon, click Chart series>Add Many Series
Select all the cells containing the data and labels for the series from the Parsed for Streamlines sheet

Change the chart type to XYScatterSmoothNoMarkers

Select Individual X values/labels for each series

click Add series
This adds all the new XY pairs as individual series in the figure

Once it's completed, the Format Chart Series button can be used to automatically format the chart.
This automatically adds arrowheads and sets the formatting of the data series.   Since there will be A LOT of series, this is a life saver.  The drawback of this operation is that it you have to edit the VBA code to change the automatic formatting properties.


Figure Generator

Matlab Streamline Code

No comments: