PTS Blog

Custom Solutions | Commercial Utilities | Training | Charts and Tutorials | PTS Blog

 

Main menu:

 
Peltier Tech
Chart Utilities

PTS Waterfall Chart Utility
PTS Cluster-Stack Column Chart Utility
PTS Box and Whisker Chart Utility
PTS Marimekko Chart Utility
PTS Dot Plot Utility
PTS Cascade Chart Utility

Subscribe

Site search

Subscribe

Site search


Recent Posts

Recently Commented

Popular Posts

Archive


 

Categories


 

Buy me a coffee

If this topic or the whole blog has been helpful, support further development by treating me to a cup of coffee.


Privacy Policy

Creative Commons License
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

Draw an Axis With Tick Marks But No Line

by Jon Peltier
Peltier Technical Services, Inc., Copyright © 2009.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

A reader asked how to make an axis that had tick marks but no line. This gives a nice clean appearance to the chart, but unfortunately cannot be done with Excel’s native axis formatting. Of course, anyone who has read my blog or my web site knows that this does not bean it can’t be done. You just have to know how to fake out Excel.

I’ll use a column chart to illustrate this technique, and I’ll also start with a little dissertation on column chart styling.

Behold the default Excel 97-2003 column chart. Functional yet oh so ugly. Muddy gray background, black border and line elements, and a nondistinct fill color.

Excel's Default Column Chart

The Excel 2007 default column chart is a little better, without the dreary background.

Excel 2007's Default Column Chart

A few minor changes to the Excel 2003 chart bring a great improvement. The gray is gone, the bar fill color is a bit nicer and the bars are a bit wider, the font isn’t so huge, the gridlines are lightened a bit, the plot area has been expanded to fill the chart area, and the extraneous tick marks along the category axis are removed.

Improved Column Chart with Dark Borders

You can lighten the gridlines, borders, and axes a bit more to help emphasize the data.

Improved Column Chart with Medium Borders

You can remove the border, leaving axes only, and you can remove the gridlines.

Improved Column Chart with Medium Axes and No Borders

Some people like the gridlines, and if you keep them you can remove the Y axis line and tickmarks. This is a pretty nice style for a column chart

Improved Column Chart with Medium Gridlines and No Y Axis

But how can you remove the axis line and the gridlines, and leave only tick marks? Excel doesn’t provide for tickmarks without the axis line too. But you can build your own set of tick marks.

One way to do this is to add a helper XY series with hidden markers but visible error bars. Here is the data range for this example. The yellow range contains the column chart data. The green range contains the data needed for the XY series; The X values place the points along the left hand axis, and the Y values position a point at each axis tick location. The blue range contains the custom value for the error bars: adjustments can be made to the size of the error bars by editing this value, instead of using the Format Error Bars dialog.

Tick Mark Data

Start by hiding the axis ticks and lines, but leaving the tick labels.

Improved Column Chart with No Y Axis

Copy the XY series data (green shaded range), select the chart, and use Paste Special to add the data as a new series. The series is initially formatted as another column series.

Adding Tick Marks Step 1

Right click on the new series, choose (Change) Chart Type, and select an XY chart type. Excel initially places it on the secondary axes, and adds nice dark axes to the chart.

Adding Tick Marks Step 1

Format the XY series. and place it on the primary axes. Now it is properly aligned in the chart.

Adding Tick Marks Step 1

Add positive X error bars to the XY series, using the blue-shaded cell for the custom value.

Adding Tick Marks Step 1

Format the series to hide it: no lines and no markers.

Adding Tick Marks Step 1

Finally format the error bars: use a medium gray instead of black, and use the stule with a line only, no end cap. If you need to change the length of the error bars, simply fiddle with the value in the blue-shaded cell.

Improved Column Chart with Medium Tick Marks

This is also a very clean style for a column chart. The same technique can be used on most other chart types.

Possibly Related Posts:

Bookmark and share this entry:
  • Digg
  • del.icio.us
  • Facebook
  • Technorati
  • Twitter
  • StumbleUpon
  • Google Bookmarks
  • Reddit
  • MySpace
  • Slashdot
  • LinkedIn
  • Yahoo! Buzz

Learn how to create Excel dashboards.

Comments


Comment from Andy Pope
Time: Thursday, April 16, 2009, 6:11 am

You could use a custom number format such as

General” ─”

where the extra character is Box Drawings Light Horizontal, U+2500 found via the Character Map program.

Admittly it doesn’t quite reach the edge of the plot area.


Comment from Jon Peltier
Time: Thursday, April 16, 2009, 6:37 am

Andy – The dashes might also be offset vertically by a pixel or two. But for quick & dirty, it’s probably fine.


Comment from Danièle
Time: Thursday, April 16, 2009, 9:04 am

“quick and dirty”?! Perfectionists..!
I had used previously the dummy series trick, but Jon, how would you go about offsetting the ticks vertically ( or horizontally)”a pixel or 2″ ?
Thanks Andy for the format idea, but my character map does not have fonts Box Drawings Light Horizontal , and how do you use the Unicode U+2500?


Comment from Jon Peltier
Time: Thursday, April 16, 2009, 9:24 am

Danièle -

What I meant is that the dash is guaranteed not to be in the middle of the label, so it will be offset from the “actual” tick mark. For my dash, I’d probably use an en-dash (–) or an em-dash (—), which are Alt+0150 or Alt+0151 on the numeric keypad.

Here’s a sample using an en-dash:

If I include horizontal gridlines, you can see that the dashes are a pixel lower than the gridlines. For quick & dirty, I guess that’s close enough.


 


Comment from Andy Pope
Time: Thursday, April 16, 2009, 9:24 am

Danièle,

The font is Arial. The Box Drawing bit is the name of the specific glyph.
If you display Unicode character set it is about 4/5ths of the way down the list.

Jon’s right about the pixel offset. It’s more prominent if you use the standard keyboard dash character.

You could use this command in the Immediate window to create the character in the active cell. Then use copy/paste

activecell.Value = chrw(&H2500)


Comment from Jon Peltier
Time: Thursday, April 16, 2009, 9:29 am

Andy -

Your symbol is perfectly aligned:


 


Comment from derek
Time: Thursday, April 16, 2009, 2:33 pm

Another quick and dirty method I often use is only slightly quicker and dirtier than Jon’s helper series, because it is itself and XY scatter series. But it’s slightly simpler:

xy
0.5 0
0.5 6

If it chooses the secondary value scale, choose the primary again, then format the line so it’s white and thick. It will cover up the scale line but leave the scale ticks visible.


Comment from Jon Peltier
Time: Thursday, April 16, 2009, 3:03 pm

Just to clarify, because it took me 30 seconds to figure out your trick.

Derek is adding a new XY series which has its endpoints at the top and bottom of the Y axis. He is displaying no markers, and a white line which obscures the axis line.

Here’s the data, the initial chart, and the data added as a new (column) series.

   

Here the new series has been converted to an XY series, the XY series moved to the primary axis, and the series formatted to show no markers and a while line.

   
 


Comment from Danièle
Time: Friday, April 17, 2009, 5:38 am

Thanks Jon and Andy. Your quick and dirty tips are as usual far from that, and thoroughly thought out for proportions and visual balance, and it is always great to see a graph where all fits well, and can be easily incorporated in a VBA module.
Derek, your trick is pretty quick, simple and effective too.
Great!
Danièle


Comment from ckz
Time: Friday, April 24, 2009, 11:23 am

Jon,

Is it possible to have a Change Event work based on a cell formula? I have only read that the actual cell has to change.

I would like to have images appear, disappear on a summary worksheet based on the values being calculated on a different worksheet.

So far, the code only works if I change a specific value in a cell on the same worksheet.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Range(”f4″), Target) Is Nothing Then

If Intersect(Range(”f4″), Target) < 5 Then
ActiveSheet.Shapes(”Object 2″).Visible = True
Else: ActiveSheet.Shapes(”Object 2″).Visible = False
End If
End If

End Sub

Any suggestions?


Comment from Jon Peltier
Time: Friday, April 24, 2009, 12:47 pm

The Change event needs an actual change to a cell’s contents: a changing value, or a change to the formula, not to its calculated value. But you could use the Calculate event to trigger the code you want to run.

Write a comment

I welcome comments from my readers. If you have an opinion on this post, if you have a question or if there is anything to add, I want to hear from you. Whether you agree or disagree, please join the discussion.

If you want to include an image in your comment, post it on your own site or on one of the many free image sharing sites, and include a link in your comment. I'll download your image and insert the necessary html to display the image inline.

Read the PTS Blog Comment Policy.





Subscribe without commenting

PTS Waterfall Chart Utility PTS Cluster-Stack Column Chart Utility PTS Box and Whisker Chart Utility PTS Marimekko Chart Utility PTS Dot Plot Utility PTS Cascade Chart Utility

Create Excel dashboards quickly with Plug-N-Play reports.