EXCEL : two-bar, 2-axis histogram - excel

I hope to show an two-bar, 2-axis histogram but when i do that on EXCEL I get an stacked, 2-axis histogram
The result I currently want is like that :

Rightclick the Chart select CHANGE CHART TYPE change chart type to CLUSTERED:

Related

How to specify x-labels in excel chart as "2019-01", "2019-02" ,etc?

I have a series of data in excel as follow:
x: [2019-01, 2019-02, 2019-03, 2019-04]
y: [12, 13, 12.7, 13.4]
I want to plot y vs. x so that x labels on x-axis be displayed as "2019-01", "2019-02" , etc. How can do this job in excel?
Just format your source data the way you'd like it to appear on the chart. To make the dates appear this way in the cells, format cells > Number format > Custom > then type yyyy-mm in the Type field and click okay. The date formatting of the chart axis should default to match the source data. Here is a snip. If you don't want to change the source data format, then select the axis and in Chart Options > Axis Options > Number > Change the format there.

Hide/add legend to graph with conditions

I have 2 columns of data for my chart, but the second one is optional (with an IF formula).
I want the legend to only show the relevant series.
Because the legend is visible even if there is no data for the second column, I wrote this in the cell for the series name:
=IF(…………;"blabla";"")
Now the legend has no label and only the (yellow dashed) line appears:
How can I hide both the label and the line in this legend if the series has no data?
You can use VBA to realize this.
in Excel 2013 onward model
you can use Chart.FullSeriesCollection to select your series and toggle its Isfiltered properties
Like
If.....Then
ChartObjects("xxxx").Chart.FullSeriesCollection(2).IsFiltered = True
Else
ChartObjects("xxxx").Chart.FullSeriesCollection(2).IsFiltered = False
End if
If you are using old excel, like excel 2007, excel 2010.. you should only use Chart.legend.legendEntries(2).Delete to get rid of the legend. if you wanna toggle it back, you should use chart.hasLegend = false, Chart.hasLegend = true to make it back

How to create a text based Y axis on excel chart

I wish to customized the Y-axis to text instead on value.
Is there any way I can do it without any plugin?
Here will be my data:
A B C D
1 Lower Limit Upper Limit # Data
2 30S 40S A1234 30A
3 30S 40S A2345 30S
4 30S 40S A1256 30S
I wish my Y axis will be 30S, 30A, 40A, 40S intead of 10,20,30,40
and my X axis will be A1234,A2345,A1256
Is there any possible that I can change the X axis value?
I started with your data, and I added a small lookup table. I inserted a column "Value" (blue text) in your data range that has the Y value corresponding to the label in your "Data" column. You can use a lookup formula for this, for example, the formula in D2 is:
=INDEX($H$2:$H$5,MATCH(E2,$I$2:$I$5,0))
I made a column chart (don't know what type of chart you want, but this technique is widely applicable) using the yellow shaded range in the first data range (top left chart). I selected and copied the green shaded range in the second data range, selected the chart, and used Paste Special to add the data to the chart, using the settings shown in the dialog overlying the top right chart.
This has added another set of columns (bottom left chart), not so useful. I right-clicked the added series, picked Change Series Chart Type from the pop-up menu, and changed just this series to an XY scatter type (bottom right chart).
The XY scatter series is on the secondary axis, also not too useful. I formatted the XY series, and changed the axis to Primary (top left chart below). The 0.5 values in column G make the points line up with the vertical axis of the chart.
I added data labels to the XY series, shown in orange to distinguish them from the black axis labels (top right chart below). I formatted the labels so they appear to the left of the points, and so they used the Value from Cells option, based on the labels in I2:I5 (middle left chart below). If you don't have Excel 2013, you don't have this option, but you could
Manually type the desired text into the labels.
Link each label to the desired cell: select the labels (one click), select the desired label (second click), type = in the formula bar, select the cell, press Enter, repeat for all labels.
Use a third-party add-in like Rob Bovey's free Chart Labeler from appspro.com.
I hid the default axis labels. You can select None for axis labels, and then resize the plot area to make room for the custom labels created above. But I used a custom number format for the axis, which consisted of several space characters enclosed in double quotes. See middle right chart below.
Finally I rescaled the vertical axis so its min and max were 0 and 40 and the major spacing was 10, I formatted the XY series to use no markers, and I changed the label font color back to Automatic (bottom chart).

Programmatically adding excel data labels in a bar chart

I try to add a bar chart to an excel file.
I am using ABL (4GL) to do this:
ASSIGN
vchChart = chExcelApplication:Charts:Add()
vchChart:ChartType = 57
vchChart:HasTitle = FALSE.
vchChart:SetSourceData(chWorkSheet2:Range("B1:B" + STRING(iCounter - 1))).
vchChart:ApplyDataLabels(5).
vchChart:Location(2, "Tabelle1":U).
This creates a bar chart, but the labels for the data are 1,2,3,4,...
I would like to use a range of fields in excel to display as the labels for the chart bars.
This should look something like this:
If I were to do this manually I would use the following in Excel:
How can I add those labels programmatically?
That means I would like to use a certain range of cells for the labels as indicated in this pseudy code:
SetLabels(chWorkSheet2:Range("A1:A" + STRING(iCounter - 1))).
If these labels are in a worksheet range, then something like this (this is VBA; make its syntax compatible with the program you're using):
ActiveChart.SeriesCollection(1).XValues = chWorkSheet2.Range("B1:B" + STRING(iCounter - 1))

Change orientation of chart and legend using excel VBA

For some reason if there is less than four rows of data and you try and scatter chart it the cluster (column A) is shown on the legend, but if more than 4 rows of data exist then the other columns (A, B, C) are on the legend (Y axis).
Can you please show me using VBA how do I re orientate this graph to look like graph (2)?
I need to reorient the legend series to be on the horizontal category axis using VBA(since the macro recorder doesn't show how to do this.
GRAPH 1 STARTS OFF LOOKING LIKE THIS
GRAPH 2 THIS IS HOW I DO IT MANUALLY
(reorient legend entries - left, and category labels - right)
GRAPH 3 The scatterchart dialog ends up looking like this, which is what I want to do in VBA
GRAPH 4 Final Graph looks like this, This is what I want to achieve in VBA
Lastly this is what the macro recorder creates, but when I try and run it, its missing, the range and Plotby parameters and fails
Range("A1:D3").Select
Range("D3").Activate
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData
Your columns and rows are reversed. When you have the chart selected go und "Design" contextual tab and click "Switch Row/Column". Does that fix it? If yes you can use:
ActiveChart.PlotBy = xlRows or ActiveChart.PlotBy = xlColumns
to do it programatically.

Resources