Overlapping X-axis Values at The Origin of The Graph

조회 수: 5 (최근 30일)
AE104
AE104 2022년 3월 4일
답변: Poorna 2023년 11월 21일
Hello,
While I am plotting the data, the x-axis values are overlapping at the origin of the graph. Why does it happen and how can I solve this issue? Attached figure shows the issue.
Thank you,
scale_max_time = double(app.max_time_value)/2.0*19.6; % 19.6 us is time resolution based on the sampling rate. The sampling rate 51 kSps (100 Mhz (core clock)/4= 25 MHz. 25 MHz/ (480 + 12)).
timevalues = 1.0:19.6:scale_max_time; % 19.6 us is time resolution based on the sampling rate. The sampling rate 51 kSps.
array_max = ceil(app.max_time_value/2);
if (array_max > 1100)
array_max = 1100;
end
cla(app.UIAxes2);
hold(app.UIAxes2, 'on');
%colors = ['r', 'g', 'b', 'm', 'k', 'w', 'k', 'c','r', 'g', 'b', 'y', 'm', 'w', 'k', 'c'];
colors = [0 0.4470 0.7410; 0.8500 0.3250 0.0980; 0.9290 0.6940 0.1250; 0.4940 0.1840 0.5560; 0.4660 0.6740 0.1880; 0.3010 0.7450 0.9330; 0.6350 0.0780 0.1840; 0 0 1; 1 0 0; 0 1 0; 0.15 0.15 0.15; 0.47 0.67 0.19; 1 0.41 0.16; 0.39 0.83 0.07; 0.06 1 1; 0.72 0.27 1];
legend_count = 1;
legend_str{1} = "";
for dmux = 1:16
for mux = 1:16
if ((app.dmux_arr(dmux)==1) && (app.mux_arr(mux)==1) && (dmux==mux))
legend_str{legend_count} = strcat('CH #', num2str(mux));
legend_count = legend_count + 1;
plot(app.UIAxes2, timevalues, squeeze(app.Voltages_Electrodes(dmux, mux, 1:array_max)), 'Color',colors(mux,:));
app.Gauge.Value = (((app.Voltages_Battery(dmux, mux, 1))*100)/8.4);
end
end
end
legend(app.UIAxes2,legend_str,'AutoUpdate','off');
yline(app.UIAxes2, 0);

답변 (1개)

Poorna
Poorna 2023년 11월 21일
Hi AE104,
I understand that you are encountering the issue of overlapping x-axis tick values in your plot.
This problem typically occurs when the x-ticks are tightly packed together. You can refer to the following solutions to address this issue and improve the readability of your plot:
  • One approach is to increase the size of the plot, which provides more space for the x-axis labels. By enlarging the plot, you can create more room for the x-axis ticks to be displayed without overlapping.
  • Another option is to limit the x-axis to a specific region of interest. By focusing on a particular x-axis range, you can allocate more space for the x-axis ticks. You can achieve this by using the "xlim" function, which allows you to set the lower and upper limits of the x-axis accordingly. A sample code is given below
xlim([x_min, x_max]);
  • Additionally, you can specify your own custom x-ticks using the "xticks" function. This provides you with the flexibility to choose and display specific x-tick values that are relevant to your data. By manually selecting the x-ticks, you can ensure that they are appropriately spaced and avoid overlapping issues. A sample code is given below.
xticks([-5 -2.5 -1 0 1 2.5 5])
Please refer to the following documentation to know more about the “xlim” and “xticks” functions.
Hope this Helps!
Best regards,
Poorna.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by