Using Excel VBA to individually color y-axis lables - excel

I'm trying to figure out how to change the color of individual y-axis labels programmatically for a bar chart. Here's what the chart currently looks like:
Here's how I'd like it to look. (The colors on the "RX 5700 XT" lines are in red -- this is via a hasty PhotoShop hack, so this isn't set in stone, just an example of where I'm headed).
The problem is, I can't seem to find a way to programmatically get at the individual text labels. The actual text isn't necessarily hard-coded, but based on matching some pattern I want to change the text colors -- a secondary coding of data, if you will.
Background: This is for my charts at Tom's Hardware, for GPU reviews specifically. In this case, I have all GPUs tested with one CPU colored one way (lighter grey and red), and all GPUs tested with a different CPU colored a different way (darker grey and red). However, I also want to potentially differentiate between AMD and Nvidia GPUs -- so highlight the AMD GPUs in Dark Red text as an example.
There are about 60 charts total, so manually changing colors on each chart after generation would be extremely inefficient. I could just use different bar chart colors, but that also gets messy. Theoretically, I want to get at myChart.Axes(xlCategory).Format.TextFrame2.TextRange ... but TextFrame2 is a read-only property. I recorded a macro where I changed the axis font color, but even that macro fails to play back properly. :\

The axis labels on a chart cannot be colored individually. The axis font color applies to all text in the axis. Individual axis labels cannot be formatted differently. Not in the GUI and not with VBA.
Side note: You may want to review your color choices for the charts. The black/red/white in such close proximity is very hard on the eyes and causes eye strain and flimmer for some people.

Related

Is there a way to transform rectangle into any shapes in MS Excel?

In MS Excel, I applied conditional formatting to a cell A1 so that it's color changes from blue at value 0 and red at value 100. I copied that cell and pasted it as linked picture(I) specially.(Paste Special). The color of the rectangle picture now changes if value in original cell is changed. The problem is, the shape is only rectangular, it can be converted into square and diamond shape at best.If same rectangle can be transformed into different shapes(maybe by adding extra anchor on rectangle shape), a heat map can be created easily. Please share your insights about this thing if there is a way.
Following pictures may help understand the problem:
[Example][1]
If you want a heat map, please consider using a CHART not gazillions of picture objects, colored/placed/rotated/etc to ... mimic a chart.
First, google anything about "surface chart" in Excel, see how it looks in Excel, whatever. Just see it and think about it so you can compare it to your current approach.
You will observe some things, like:
it's 3D
it has just a few layers/colors
etc.
But really, all of them can be solved. Probably easier than your current approach.
you can easily turn off both axes and you can rotate it so the camera is totally straight top-down - then it looks flat as paper and noone can see it as 3D anymore
you can add more layers, you can set each of them to specific colors
etc.
Some resources:
multiple colors in surface chart
how to change rotation of 3d chart
geesh, I just found even a whole article/tutorial dedicated to creating heat map charts.
Please, read that last link and I'm pretty sure you will want to use that approach instead of doing picture puzzles.

Creating a histogram with numerical x-axis in excel

I would like to create a bar-chart (or a histogram?) with vertical bars and a numerical x-axis , but I do not know how/where to start. I have MS-Excel and Origin-plot available with me. My intended chart would look like this:
You can more or less get what you want by adding and styling error bars appropriately to a scatter plot. The error bar is a simple way to force Excel to draw a line under/over the point.
Chart with data and error bars
Couple steps
Make an XY scatter chart
Add the error bars and delete the horizontal ones that come up
Set the negative error bar for the points to be equal to the same value that is being plotted
Set the positive error bar to 0 so it does not show
Change the formatting on the error bar to be thicker
Possible hide the initial dot shown so that it is bar only
You could take these steps and codify them with some VBA to prevent the tedious nature of doing this multiple times. Setting error bars is one of the worst activities to have to do continually.
I believe you should also be able to get your desired colors by adding multiple series. Possibly all the more reason to do this with VBA.

Excel: Color Code Subset of Pie Charts

Hello, I was wondering if it is possible to color code groups of the pie chart together, but not manually do it slice by slice. For example, Apartments would be grouped together as light blue, and then Self Storage as dark blue. The pieces would retain their original percentage still though. This would make it easier to identify groups of data more easily. Any input?
Thanks in advance for the help.
Any input? Well, first, don't use pie charts for charts with more than two or three data points. They are hard to interpret. Use horizontal bar charts instead.
The data seems to be sorted by value. If you want to group by category, you will need to sort by category, too.
Excel will automatically apply a different color to each pie chart wedge. You can manually change these colors. You can use VBA to automate that.
A horizontal bar chart will give you a lot more tools to visualize the data and turn it into information.

How to plot Bubble chart with plots outside axis area using Excel

Im using Excel for Mac 2011 and I have the following figure
I would like to still show the bubbles outside of the available chart area, while keeping the maximum and minimum axes values unchanged.
Create an identical chart with the same data, but with axis limits that show the full bubbles. Then set all the formatting in the chart other than the bubbles to the equivalent of "none", i.e, no axis labels, chart outlines, gridlines, chart and plot borders, background color, etc.
With very careful sizing and positioning of this bubbles-only chart over the original chart, you can get the bubbles to extend beyond the plot area of the original. If the size or position of a bubble is a little off, modify the overlay chart's data by the tiny amount needed to get the bubble to cover the underlying original bubble. Turn off the formatting for the underlying bubbles as last step.
NOT programmatic, very trial and error, and fussy, of course, and I hope someone comes up with a more elegant way to achieve your goal. But I was able to get it to work on my Windows machine.

Partially missing gridlines on log-scale charts in Excel 2007

I'm using Excel 2007 to create a log-scale chart of numbers (specifically the Zimbabwean dollar exchange rate) over time. I'm using an x-y scatterplot and noticing one odd quirk.
The range of y values (numbers) spans a factor of about 10^30. On every chart I make using this data, half the gridlines are missing. Specifically, only the gridlines corresponding to the largest values show up. In fact, regardless of the total range only the top factor of 10^13 or so have gridlines. This is not dependent on the log base.
Am I doing something wrong? Is this a known bug? I can't find any references to this issue on google or microsoft's bug reports.
Silly work around as well, but if you are going to be presenting your graph in Powerpoint, you can make the background color of the graph "no fill" and then when you paste it into Powerpoint (I paste it as a PDF). You can draw grid lines and match them up with the ticks on the y-axis. Arrange your graph "bring to front" when you are finished drawing so that the lines won't appear in front of your data. You can group it all to make sure the lines don't shift while making your presentation and so that they re-size properly if you re-size your graph.
I'm having the same problem, it's definitely a bug.
Try a sequence 1, 10, 100, 1e+12, 1e+30 vs 0..4 and plot x,y scatter, and clearly the scale grid is messed-up even in linear, and in log is the behaviour you described.
My workaround was to make a transformation of the values and depict them scaled down (by a Million factor). That way the data the graph is handling is never above 10e9 (the value I started to hit issues).
So, my suggestion is: graph a Log version of the data (and clearly make a legend for it)
I was able to replicate your problem and come up with a pseudo-workaround.
The formatting goes a bit funny, but all the lines show up if you right-click on the axis, select Format Axis. Under the Axis Options, there is a Horizontal Axis Crosses setting. Changing it from Automatic to Maximum Axis Value causes all the gridlines to appear.
Ran into same thing: Will not show log grid lines for y-axis ranging below 1e-7. Have need for dynamic range of 1e5 down to 1e-15. Tagging auto or max will show grid, but puts axis labels in non-useful place for display.
My workaround: used Open Office to get what I needed. Could not find useful solution in Excel 2010.

Resources