Plot produces blank figure.

99 ビュー (過去 30 日間)
David Rainbeau
David Rainbeau 2016 年 5 月 9 日
コメント済み: Nicholas Jackson 2018 年 8 月 14 日
Taking a course and running through a very simple example, but my Figure opens with just a blank black image. The data looks like it is loaded properly into X and y. Any guidance would be great.
clear ; close all; clc
fprintf('Plotting Data ...\n')
data = load('ex1data1.txt');
X = data(:, 1); y = data(:, 2); m = length(y);
% Plot Data
plotData(X, y);
fprintf('Program paused. Press enter to continue.\n');
pause;
% Function %
function plotData(x, y)
figure;
plot(x, y, 'rx', 'MarkerSize', 10);
ylabel('Profit in $10,000s');
xlabel('Population of City in 10,000s');
end
  2 件のコメント
Adam
Adam 2016 年 5 月 9 日
Have you stepped through with the debugger to look at x and y?
It's difficult to suggest anything as we don't have your data and nothing jumps out from the code to me as being blatantly wrong.
Also have you tried it without the 'pause' instruction? It may just be a case of the plot not being drawn yet because it is paused.
Walter Roberson
Walter Roberson 2016 年 5 月 9 日
pause() triggers drawing so that is not the reason.

サインインしてコメントする。

採用された回答

David Rainbeau
David Rainbeau 2016 年 5 月 9 日
I tracked this down to being a video card issue. Was led to this conclusion through http://www.mathworks.com/help/matlab/ref/opengl.html. When I changed from opengl hardware to opengl software, the plot worked properly.
Even though my Matrox M-9148 card only supports OpenGL 2.0 (not 2.1), once I update the drivers, the hardware works without having to rely on using software.
  1 件のコメント
Nicholas Jackson
Nicholas Jackson 2018 年 8 月 14 日
Thanks! This fixed mine too

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by